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

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

Reply
Shivkanyabyale
Frequent Visitor

Get Data from folder

 

I am tring to get data from folder where i have multiple excel files but when i am tring combine and transform after Expanded table
query i am getting data with column headers which are static i only what data without header this is happing only in one column 
how to get data without static headers 



let
Source = Folder.Files("\\server-new\D\SERVER DATA BACKUP\Server Data Backup\Consultancy\Power BI\Clients Analysis\Dashboard\ERP\Sales"),
#"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", Table.ColumnNames(#"Transform File"(#"Sample File")))
in
#"Expanded Table Column1"


 this are the steps in  power query 
i want to combine multile 


Screenshot1 2024-12-17 191526.png

 

My first 2 lines may be different in different excel so i want to remove those 2 lines before headers get promoted but when i expand table automatically headers are getting promoted ,i wanted to promate headers after removing 2 lines but not able to do so becasue when i expand data it automatically getting headers prommoted for one column 
can anyone tel me how to get cololumns after expand table wither romoting headers so i can remover 2 rows then use pramote header step 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from lbendlin , please allow me to provide another insight:

Hi, @Shivkanyabyale 
Thanks for reaching out to the Microsoft fabric community forum.

The most straightforward solution at present is to add a column to delete rows based on the differences in Source.Name:

 

1.Here is my sample data:

vlinyulumsft_0-1734601016110.png

2.I inserted a custom column:

vlinyulumsft_1-1734601016110.png

if [Source.Name]= "1.csv" then Table.RemoveFirstN([Transform File], 3) 
else if [Source.Name]= "2.csv" then Table.RemoveFirstN([Transform File], 5) 
else [Transform File]

vlinyulumsft_2-1734601071233.png

In the red box above, you can adjust the M language as needed:Table.RemoveFirstN(), Table.RemoveLastN(), and Table.RemoveRows() functions.

For more details, please refer to:

Table.RemoveFirstN - PowerQuery M | Microsoft Learn

Table.RemoveLastN - PowerQuery M | Microsoft Learn
Table.RemoveRows - PowerQuery M | Microsoft Learn

3.Then proceed to delete the excess columns.

4.Below is the complete M language:

let
    Source = Folder.Files("C:\Users\v-linyulu\Desktop\combine"),
    #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
    #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
    #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File"}),
    #"Added Custom" = Table.AddColumn(#"Removed Other Columns1", "Custom", each if [Source.Name]= "1.csv" then Table.RemoveFirstN([Transform File], 3) 
else if [Source.Name]= "2.csv" then Table.RemoveFirstN([Transform File], 5) 
else [Transform File]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Transform File"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Country", "City", "Latitude", "Longitude", "Sales"}, {"Custom.Country", "Custom.City", "Custom.Latitude", "Custom.Longitude", "Custom.Sales"})
in
    #"Expanded Custom"

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

3 REPLIES 3
Anonymous
Not applicable

Thanks for the reply from lbendlin , please allow me to provide another insight:

Hi, @Shivkanyabyale 
Thanks for reaching out to the Microsoft fabric community forum.

The most straightforward solution at present is to add a column to delete rows based on the differences in Source.Name:

 

1.Here is my sample data:

vlinyulumsft_0-1734601016110.png

2.I inserted a custom column:

vlinyulumsft_1-1734601016110.png

if [Source.Name]= "1.csv" then Table.RemoveFirstN([Transform File], 3) 
else if [Source.Name]= "2.csv" then Table.RemoveFirstN([Transform File], 5) 
else [Transform File]

vlinyulumsft_2-1734601071233.png

In the red box above, you can adjust the M language as needed:Table.RemoveFirstN(), Table.RemoveLastN(), and Table.RemoveRows() functions.

For more details, please refer to:

Table.RemoveFirstN - PowerQuery M | Microsoft Learn

Table.RemoveLastN - PowerQuery M | Microsoft Learn
Table.RemoveRows - PowerQuery M | Microsoft Learn

3.Then proceed to delete the excess columns.

4.Below is the complete M language:

let
    Source = Folder.Files("C:\Users\v-linyulu\Desktop\combine"),
    #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
    #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
    #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File"}),
    #"Added Custom" = Table.AddColumn(#"Removed Other Columns1", "Custom", each if [Source.Name]= "1.csv" then Table.RemoveFirstN([Transform File], 3) 
else if [Source.Name]= "2.csv" then Table.RemoveFirstN([Transform File], 5) 
else [Transform File]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Transform File"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Country", "City", "Latitude", "Longitude", "Sales"}, {"Custom.Country", "Custom.City", "Custom.Latitude", "Custom.Longitude", "Custom.Sales"})
in
    #"Expanded Custom"

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

 

Thank you for your responce @Anonymous ,your solution solved my problem.

lbendlin
Super User
Super User

Modify the "Transform File"  function  or implement the combine yourself if you want to avoid all the extra boilerplate code.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.