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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mlsx4
Memorable Member
Memorable Member

Efficient append of Excels & sheets

Hello everyone!

 

I have several Excels (one per year) with different sheets, but same structure (one per center). At the end I need all of them to be combined in a unique table to manage properly all information. I have done it but in a very inefficient way, since Power BI shows a lot of times OutofMemory Exception. 

 

Excel 2023: has 29 sheets with exactly same structure.

Excel 2024: has 29 sheets with exactly same structure.

 

The thing is that I need to keep year and center code (which is in the name of the sheet) to be able to differentiate data.

 

Thanks for your help

1 ACCEPTED SOLUTION

@mlsx4 sure. Takes some extra efforts. Hope this won't ruin performance.

let
    Source = Folder.Files(path_to_folder)[[Name], [Content]],
    all_data = Table.TransformColumns(Source, {"Content", Excel.Workbook}),
    expand01 = Table.ExpandTableColumn(all_data, "Content", {"Data", "Item", "Kind"}),
    sheets = Table.SelectRows(expand01, each [Kind] = "Sheet")[[Name], [Item], [Data]],
    promote = Table.TransformColumns(sheets, {"Data", Table.PromoteHeaders}),
    rename = Table.RenameColumns(promote,{{"Name", "file_name"}, {"Item", "sheet_name"}}),
    headers = Table.ColumnNames(rename{0}[Data]),
    expand = Table.ExpandTableColumn(rename, "Data", headers)
in
    expand

 

View solution in original post

8 REPLIES 8
VahidDM
Super User
Super User

Hey @mlsx4 

 

have you seen this:

https://m.youtube.com/watch?v=SzOk1xjx2z4

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

mlsx4
Memorable Member
Memorable Member

Hey @VahidDM 

 

I need to take a deeper look but... I think your link will only solve the problem of appending data inside an Excel, but how to merge all excels in the folder?

Check these 2:

https://m.youtube.com/watch?v=Nbhd0B5ldJE


https://m.youtube.com/watch?v=nPlrQUbEn4o

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

 

mlsx4
Memorable Member
Memorable Member

Hi @VahidDM 

 

Thank you for your effort but all these links has only one of the conditions. I mean combine different Excels workbooks (with only one sheet) or combine multiple sheets (with only one Excel). I need to do both...

Hello, @mlsx4 assumption: the only transformation you need is to promote headers of the tables. Keep an eye on your headers. If "Item" is one of the column names then rename a column with sheet name before expand step (now it's called "Item").

let
    Source = Folder.Files(full_path_to_your_folder)[Content],
    all_data = Table.Combine(List.Transform(Source, Excel.Workbook)),
    sheets = Table.SelectRows(all_data, each [Kind] = "Sheet")[[Item], [Data]],
    promote = Table.TransformColumns(sheets, {"Data", Table.PromoteHeaders}),
    headers = Table.ColumnNames(promote{0}[Data]),
    expand = Table.ExpandTableColumn(promote, "Data", headers)
in
    expand
mlsx4
Memorable Member
Memorable Member

Hi @AlienSx 

 

It almost works perfectly. My problem is that I'm missing the name of the workbook which is key for me because it contains the year... Is there any workaround?

@mlsx4 sure. Takes some extra efforts. Hope this won't ruin performance.

let
    Source = Folder.Files(path_to_folder)[[Name], [Content]],
    all_data = Table.TransformColumns(Source, {"Content", Excel.Workbook}),
    expand01 = Table.ExpandTableColumn(all_data, "Content", {"Data", "Item", "Kind"}),
    sheets = Table.SelectRows(expand01, each [Kind] = "Sheet")[[Name], [Item], [Data]],
    promote = Table.TransformColumns(sheets, {"Data", Table.PromoteHeaders}),
    rename = Table.RenameColumns(promote,{{"Name", "file_name"}, {"Item", "sheet_name"}}),
    headers = Table.ColumnNames(rename{0}[Data]),
    expand = Table.ExpandTableColumn(rename, "Data", headers)
in
    expand

 

mlsx4
Memorable Member
Memorable Member

Hello @AlienSx 

 

Up to now, it's working perfectly and efficiently! Thank you so much.

You're amazing!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors