Loading and combine excel files with different sheet names into Power BI


Loading and combine excel files  is quite easy by using "combine binaries" feature in Power BI.  Just following instructions in this link , you could load all files, which have the same schema, into a single logic table.
But real life always has exceptions. a business user provided me some excel files and asked me to demonstrate how to load these files and combine them into one table in Power BI this morning. When I demonstrate him how to do that,  after I choose "combine and load" ,
And:
I found the process status are all "Error" except the first file.
 Clicking on "Error", it shows the error message :
Then I noticed that the sheet name is hard-coded in "Transform Sample File from DataFileFolder" query:
and the sheet name in each excel file is different. 
To solve that issue, I replace that line of code to get records from the source, that is a table, and then get the first sheet by index. Here is the code:

#"AFD Survey - ATL Crown Owned PW_Sheet" = Table.ToRecords(Source){0}[Data]

It shows that Power Query M is a powerful tool to solve some challenges in a neat way again.




Comments