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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
acerNZ
Helper III
Helper III

Selecting a row as header

Hi Experts

I have this excel and similare excel with 100s of coloumns and and with many merged rows on the top, I need to get the a specific row where actual data start in each sheet,  

So I explored and got this link and I think, I followed but I might have made mistake

Please can you help me . 

Selecting specific row as header  solution by @edhans 

 

let
    Source = Excel.Workbook(File.Contents("C:\Data\Academic\PowerBI\Promoting_header\promoteheader.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Filtered for header row" = Table.SelectRows(#"Changed Type", each ([Data] = "Header Row")),
    #"Appended Query" = Table.Combine({#"Filtered for header row", #"Changed Type"}),
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"East", type text}, {"West", type text}, {"Central", type text}, {"Mountain", type any}, {"Column5", type any}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}, {"Column9", type any}, {"Column10", type any}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Section 1] <> null)),
    #"Filtered out header row" = Table.SelectRows(#"Promoted Headers", each ([Header Row] <> "Header Row"))
in
    #"Filtered Rows"

 

Please can you help me understand this. Currently I get expresion error: The Column "East" of the table is not found.

 

2. If I have 100s of columns, do I have to mention each coloumn in the #ChangedType

2020-11-09_12h32_57.png

2 ACCEPTED SOLUTIONS
Jimmy801
Community Champion
Community Champion

Hello @acerNZ 

 

with this function you are reading your whole worksheet. In your case you have to skip the first 3 lines and then promote the headers. Here the code

let
    Source = Excel.Workbook(File.Contents("YourFile.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    TableSkip = Table.Skip(Sheet1_Sheet, 3),
    #"Promoted Headers" = Table.PromoteHeaders(TableSkip, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"East", type any}, {"West", type any}, {"Central", type any}, {"Mountain", type any}, {"Column5", type any}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}, {"Column9", type any}, {"Column10", type any}})
in
    #"Changed Type"

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

edhans
Super User
Super User

Hi @acerNZ ,

 

You didn't specify, but if the first column always has "East" in it, you can use this method:

 

let
    Source = Excel.Workbook(File.Contents("C:\Users\User Path\Downloads\promoteheader.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    FindFirstRow =
        List.PositionOf(
            Sheet1_Sheet[Column1],
            "East"
        ),
    SkipToFirstRow = 
        Table.Skip(Sheet1_Sheet, FindFirstRow)
in
    SkipToFirstRow

 

It uses the logic and steps in this blog I wrote last week.

 

The above code will put your East, West, etc. as the first row. Then you can do the Promote to Header and continue with your transformations.

 

If your data always just has 3 bogus rows in the top, there is no need to find the row East is on. Just use the Remove Top Rows feature in the home ribbon, and type 3 for the rows to skip.

edhans_0-1604940400216.png

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

7 REPLIES 7
acerNZ
Helper III
Helper III

@edhans Thank you for your time and help, I tested  your solution as well and it really works. Cheers

So we have 2 solutions which work perfectly. I will follow your blog @edhans .. thanks a ton

Great @acerNZ. Glad to be of assistance. Thanks for following the blog. 😁



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
edhans
Super User
Super User

Hi @acerNZ ,

 

You didn't specify, but if the first column always has "East" in it, you can use this method:

 

let
    Source = Excel.Workbook(File.Contents("C:\Users\User Path\Downloads\promoteheader.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    FindFirstRow =
        List.PositionOf(
            Sheet1_Sheet[Column1],
            "East"
        ),
    SkipToFirstRow = 
        Table.Skip(Sheet1_Sheet, FindFirstRow)
in
    SkipToFirstRow

 

It uses the logic and steps in this blog I wrote last week.

 

The above code will put your East, West, etc. as the first row. Then you can do the Promote to Header and continue with your transformations.

 

If your data always just has 3 bogus rows in the top, there is no need to find the row East is on. Just use the Remove Top Rows feature in the home ribbon, and type 3 for the rows to skip.

edhans_0-1604940400216.png

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Jimmy801
Community Champion
Community Champion

Hello @acerNZ 

 

with this function you are reading your whole worksheet. In your case you have to skip the first 3 lines and then promote the headers. Here the code

let
    Source = Excel.Workbook(File.Contents("YourFile.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    TableSkip = Table.Skip(Sheet1_Sheet, 3),
    #"Promoted Headers" = Table.PromoteHeaders(TableSkip, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"East", type any}, {"West", type any}, {"Central", type any}, {"Mountain", type any}, {"Column5", type any}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}, {"Column9", type any}, {"Column10", type any}})
in
    #"Changed Type"

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Thank you Jimmy 

Worked like charm, sorry for late testing

acerNZ
Helper III
Helper III

Hey @PhilipTreacy Thanks a lot. I always struggle to upload any file here, I don't get that option and I tried again, I used github to publish, Please can you confirm, if you can see this or I will use google drive etc.

https://github.com/acerNZ/PowerBI 

Please can you confirm, if you can access this as this is my first time, I try this way.

PhilipTreacy
Super User
Super User

Hi @acerNZ 

Please supply one of the Excelworkbooks you are trying to transform.

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.