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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
cosminc
Post Partisan
Post Partisan

single base from many sources with many sheets - M language

Hi all

i need to import couple excels from a folder

and each from them has 10-12 sheets - this sheets have unique names and different from an excel to another

 so the result need to be a single base with all these

 

 

folder source with:

excel1  -->   sheet1    sheet2   sheet3

excel2  -->   sheet 10  sheet11 sheet12

excel3 -->    sheet20   sheet21  sheet22

excel4 -->    sheet30   sheet31  sheet32

 

result one single base

is it posible?

 

Thank,

Cosmin

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @cosminc ,

You can refer to this video. My test result is like below:

single base from many sources with many sheets - M language.PNG

The complete code is as follows:

let
   Source = Folder.Files("D:\Power BI\case\excel"),
    #"Removed Other Columns" = Table.SelectColumns(Source,{"Content"}),
    #"Added Custom" = Table.AddColumn(#"Removed Other Columns", "GetExcelData", each Excel.Workbook([Content])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Content"}),
    #"Expanded GetExcelData" = Table.ExpandTableColumn(#"Removed Columns", "GetExcelData", {"Name", "Data", "Item", "Kind", "Hidden"}, {"GetExcelData.Name", "GetExcelData.Data", "GetExcelData.Item", "GetExcelData.Kind", "GetExcelData.Hidden"}),
    #"Added Custom1" = Table.AddColumn(#"Expanded GetExcelData", "NoHeaders", each Table.PromoteHeaders([GetExcelData.Data])),
    #"Removed Other Columns1" = Table.SelectColumns(#"Added Custom1",{"NoHeaders"}),
    #"Expanded NoHeaders" = Table.ExpandTableColumn(#"Removed Other Columns1", "NoHeaders", {"Segment", "Country", "Product", "Discount Band", "Units Sold", "Manufacturing Price", "Sale Price", "Gross Sales", "Discounts", " Sales", "COGS", "Profit", "Date", "Month Number", "Month Name", "Year"}, {"Segment", "Country", "Product", "Discount Band", "Units Sold", "Manufacturing Price", "Sale Price", "Gross Sales", "Discounts", " Sales", "COGS", "Profit", "Date", "Month Number", "Month Name", "Year"})
in
#"Expanded NoHeaders"

Best Regards,

Icey Zhang

 

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

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @cosminc ,

You can refer to this video. My test result is like below:

single base from many sources with many sheets - M language.PNG

The complete code is as follows:

let
   Source = Folder.Files("D:\Power BI\case\excel"),
    #"Removed Other Columns" = Table.SelectColumns(Source,{"Content"}),
    #"Added Custom" = Table.AddColumn(#"Removed Other Columns", "GetExcelData", each Excel.Workbook([Content])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Content"}),
    #"Expanded GetExcelData" = Table.ExpandTableColumn(#"Removed Columns", "GetExcelData", {"Name", "Data", "Item", "Kind", "Hidden"}, {"GetExcelData.Name", "GetExcelData.Data", "GetExcelData.Item", "GetExcelData.Kind", "GetExcelData.Hidden"}),
    #"Added Custom1" = Table.AddColumn(#"Expanded GetExcelData", "NoHeaders", each Table.PromoteHeaders([GetExcelData.Data])),
    #"Removed Other Columns1" = Table.SelectColumns(#"Added Custom1",{"NoHeaders"}),
    #"Expanded NoHeaders" = Table.ExpandTableColumn(#"Removed Other Columns1", "NoHeaders", {"Segment", "Country", "Product", "Discount Band", "Units Sold", "Manufacturing Price", "Sale Price", "Gross Sales", "Discounts", " Sales", "COGS", "Profit", "Date", "Month Number", "Month Name", "Year"}, {"Segment", "Country", "Product", "Discount Band", "Units Sold", "Manufacturing Price", "Sale Price", "Gross Sales", "Discounts", " Sales", "COGS", "Profit", "Date", "Month Number", "Month Name", "Year"})
in
#"Expanded NoHeaders"

Best Regards,

Icey Zhang

 

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

Hi

it's perfect and very smart

thanks a lot!

Cosmin

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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