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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
koaoak_SN
New Member

Headers to Column - Power Query

Hey there!

 

I have a data sets from 43 locations that I am uploading from Excel. Each report has the same format for each column / column header along with Headers at the top of the report showing the report parameters (location, dates of the report, etc.).

 

In Power Query, I need to figure out how to take the location header and apply it to each row in a new column. When I have uploaded all 43 reports, they are being appended together, so the location for each property needs to be added as a column to differentiate location data. After this is done, the "junk" headers will be deleted.

 

Below is a screen shot from the scenario accomplished in Excel just in case a visual is better. 

Screenshot 2022-06-08 051436.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @koaoak_SN ,

 

1. Suppose I have a table like this.

vcgaomsft_0-1655107297034.png

let
    Source = Excel.Workbook(File.Contents("Sample\New Microsoft Excel Worksheet.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Added Custom" = Table.AddColumn(Sheet1_Sheet, "Tag", each Table.FirstValue(Table.SelectColumns(Sheet1_Sheet,"Column3"))),
    #"Promoted Headers" = Table.PromoteHeaders(#"Added Custom", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Column1", type any}, {"Column2", type text}, {"xxx-xxx", type text}, {"xxx-xxx_1", type text}}),
    #"Promoted Headers1" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers1",{{"aa", Int64.Type}, {"bb", type text}, {"cc", type text}, {"xxx-xxx", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"xxx-xxx", "Tag"}})
in
    #"Renamed Columns"

vcgaomsft_1-1655107426553.png

Repeat steps for each table.

 

2. It may be easier to add a label column to the data source.

 

Tip: Posting the power query question to the corresponding forum will get a faster and more professional solution.

Power Query - Microsoft Power BI Community

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @koaoak_SN ,

 

1. Suppose I have a table like this.

vcgaomsft_0-1655107297034.png

let
    Source = Excel.Workbook(File.Contents("Sample\New Microsoft Excel Worksheet.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Added Custom" = Table.AddColumn(Sheet1_Sheet, "Tag", each Table.FirstValue(Table.SelectColumns(Sheet1_Sheet,"Column3"))),
    #"Promoted Headers" = Table.PromoteHeaders(#"Added Custom", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Column1", type any}, {"Column2", type text}, {"xxx-xxx", type text}, {"xxx-xxx_1", type text}}),
    #"Promoted Headers1" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers1",{{"aa", Int64.Type}, {"bb", type text}, {"cc", type text}, {"xxx-xxx", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"xxx-xxx", "Tag"}})
in
    #"Renamed Columns"

vcgaomsft_1-1655107426553.png

Repeat steps for each table.

 

2. It may be easier to add a label column to the data source.

 

Tip: Posting the power query question to the corresponding forum will get a faster and more professional solution.

Power Query - Microsoft Power BI Community

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors