Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lekkerbek
Helper IV
Helper IV

Multiple sheets with the same format

I have a client who has a franchise organisation. They report the purchases of 40 shops with each supplier. There are around 30 suppliers. So basically I have an excelsheet where each sheet is a supplier and on that sheet there is a list of the 40 shops with the total value of purchases made in a quarter.

 

The format of the sheet is always the same.

 

I would like to upload the sheet into Power BI and show some reports. My first idea would be:

- upload 30 sheets

- remove rows and columns that I don't need, change format, etc

- unpivot columns

 

Problem: I don't want to do this 30 times (for each supplier). Is there a way to use the applied steps in a query in another table (sheet)?

 

After that I'm thinking about merging the tables into 1 big table by using the DAX Union function.

 

Is this the way do to it, or is there an easier way?

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

 

paste the code below in the query editor

replace file path with your file

then expand the tables using two arrows icon next to the Data column

Capture.PNG

 

 

 

 

 

let
Source = Excel.Workbook(File.Contents("C:\Users\stach_000\Desktop\data.xlsx"), null, true),
#"Removed Other Columns" = Table.SelectColumns(Source,{"Name", "Data"})
in
#"Removed Other Columns"

 

it would still require some cleaning, but it's quite fast

alternatively if sheets are not in a single file you can create function where filename would be parameter, it appends data automaticaly then



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

5 REPLIES 5
ImkeF
Community Champion
Community Champion

You need 1 function where you perform all your transformation-steps that you then apply in an add-column step. You just have to expand that column then. No need for a merge or append. It mimics the From-Folder-method, just that you don't have to split up your existing xls-sheet into separate files:

 

Excel.Workbook(File.Contents(..YourFilePath..), null, true)

This will return the content of your Excel-file in a format where the content of every sheet sits in one row:

 

 

PBI_Append_ExcelSheets.png

 

You then add a column where you pass the [Data]-column to your function - that should be it.

 

... oops - overlap with post from @Stachu who suggested the same method

Anyway - put your function into a new column 🙂

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Thank you all for the great suggestions.

 

I've tried Stachu/Imke's suggestion and (of course) needs some work, but appears to be what is the right way in my specific case. 

Stachu
Community Champion
Community Champion

 

paste the code below in the query editor

replace file path with your file

then expand the tables using two arrows icon next to the Data column

Capture.PNG

 

 

 

 

 

let
Source = Excel.Workbook(File.Contents("C:\Users\stach_000\Desktop\data.xlsx"), null, true),
#"Removed Other Columns" = Table.SelectColumns(Source,{"Name", "Data"})
in
#"Removed Other Columns"

 

it would still require some cleaning, but it's quite fast

alternatively if sheets are not in a single file you can create function where filename would be parameter, it appends data automaticaly then



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Greg_Deckler
Community Champion
Community Champion

I believe that you want an Append Query versus a Merge Query. So, 30 queries that you then append together. You can actually do this with a single query if you're OK writing the M code. I have an article on this (it deals with Merge queries but the same technique should work with Append queries: http://social.technet.microsoft.com/wiki/contents/articles/32915.power-bi-merge-query-with-m.aspx

 

Something else that you could consider, break each sheet out into its own Excel file and put them all in the same folder. You could then use Folder as a data source and it will append them all together automagically.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Vvelarde
Community Champion
Community Champion

@lekkerbek

 

In your case i 'll prefer first Merge all the sheets and then make the Transformation Data.

 




Lima - Peru

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.