


#Can i search multiple excel files at once code#
Then – and this is important – remove all the other columns in the table except the Data column:ĭoing this changes the M code generated for the next thing you’ll do removing all these columns changes the way the row is referenced (see the section on “The effect of primary keys” in this post) and makes sure the name of the worksheet won’t be hard-coded anywhere.Īfter that click the Table link inside the cell, and you’ll see the contents of the worksheet: In this case I’m using the worksheet called Q1: Now, in the Template query, select one of the worksheets to use to build the query whose logic will be applied to all the other worksheets, and filter the table above so it only contains the row for that worksheet. If you need to, filter out any rows that do not contain “Sheet” in the Kind column and also filter out any worksheets that you don’t want to combine data from.ĭuplicate the query above and call the new query Template. The result will be a table that looks something like this: In Power BI connect to your Excel file as normal, then in the Navigator pane right-click on the name of the Excel workbook and select Edit rather than selecting any of the individual worksheets: Step 1: Get a table with all the worksheets listed And yes, that is basically what needs to happen, but the devil’s in the detail. However in this particular case it doesn’t solve the problem, because we get this:Īha, you may say, we have to transform the data before we can combine it and so we need to create a function and call it for every worksheet – the technique I’ve already blogged about here.
#Can i search multiple excel files at once how to#
If each sheet has the same columns, this means you can just connect to the Excel workbook and get a table containing the contents (Miguel Escobar has a great post describing how to do this here) and then click the Expand/Aggregate button: Now most of the blog posts that describe this problem, such as Ken Puls’s post here, assume each worksheet has a table with the same column names on it. The required output for Power BI should be a table that looks like this: On each worksheet is some sales data for the three months in each quarter for example the Q1 worksheet looks like this: Let’s say you have an Excel workbook with four worksheets: Q1, Q2, Q3 and Q4. I was asked to explain how to do this recently while teaching a Power BI class, so in this blog post I’m going to walk through a worked example and point out a few issues that might trip up even experienced Power BI users.įirst of all, the source data. Indeed a lot of people have blogged about how to solve this problem, but none of the solutions I’ve found on the internet work in more complex scenarios when the data on each sheet needs some kind of transformation before it can be combined. It’s very common that you need to combine data from multiple worksheets in the same Excel workbook when you’re using Power BI or Power Query/Get&Transform in Excel.
