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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.