Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello!
I have different Excel files in different folders, all of them within a Sharepoint folder called "Root Folder". All Excel files have the name "Presentation.xlsx", but some of them have a tab called "Level" and others do not.
I want to combine all Excel files within the subfolders of the Root Folder, but only those that have the "Level" tab (because this is the tab I will use in BI). The ones that do not have this tab are causing an error when I try to combine all of them.
Is it possible to do this? A combination of Excel files that are in several different folders within my Root Folder, where they all have the same name but some of them have the "Level" tab?
Solved! Go to Solution.
Here is the general approach. Please study the code. I attached the folder structure for my test.
let
Source = Folder.Files("C:\Users\xxx\Downloads\Test"),
#"Filtered Rows" = Table.SelectRows(Source, each ([Name] = "Presentation.xlsx")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Content", "Folder Path"}),
#"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Custom", each Table.PromoteHeaders(Table.SelectRows(Excel.Workbook([Content]), each ([Name] = "Level")){[Item="Level",Kind="Sheet"]}[Data], [PromoteAllScalars=true])),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Added Custom", {"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Errors", "Custom", {"Column"}, {"Column"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Expanded Custom",{"Folder Path", "Column"})
in
#"Removed Other Columns1"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.
yes, that is possible in Power Query. What have you tried and where are you stuck?
Hello @lbendlin
I tried to combine all files named "Presentation.xlsx" that are inside any subfolders of"Root Folder" and when appeared the option to select the file on which I would base the combination, I selected a file that I know has the "Level" tab and I also selected the "Level" tab to combine.
However, the combination only gets the data from the first file and then gives an error (probably because it must also be trying to get the "Level" tab of files that do not have this tab).
How can I make this distinction, in Power Query, so that BI tries to combine only the files that have the tab named "Level"?
Here is the general approach. Please study the code. I attached the folder structure for my test.
let
Source = Folder.Files("C:\Users\xxx\Downloads\Test"),
#"Filtered Rows" = Table.SelectRows(Source, each ([Name] = "Presentation.xlsx")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Content", "Folder Path"}),
#"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Custom", each Table.PromoteHeaders(Table.SelectRows(Excel.Workbook([Content]), each ([Name] = "Level")){[Item="Level",Kind="Sheet"]}[Data], [PromoteAllScalars=true])),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Added Custom", {"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Errors", "Custom", {"Column"}, {"Column"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Expanded Custom",{"Folder Path", "Column"})
in
#"Removed Other Columns1"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
70 | |
68 | |
43 | |
34 | |
26 |
User | Count |
---|---|
86 | |
49 | |
45 | |
38 | |
37 |