Forum Discussion
Power Query Use First Row as Headers for selected (or single) Row(s)
- 1 year ago
I agree. It is amazing how this community works.
I didn't see any of those answers as a solution for my problem. I did it like this:
#"Promoted Headers Conditionally" = Table.TransformColumns(
#"Added Custom",
{
"Data",
each
if List.First(Table.ColumnNames(_)) = "Column1" then
Table.PromoteHeaders(_, [PromoteAllScalars=true])
else
_
}
If you want to rename your existing column headers using values from a specific row (like row 3), don’t promote the whole row. Instead, keep only that row, convert it to a list, and then use Table.RenameColumns() with that list to rename the headers. This lets you selectively rename columns without touching the rest of the table. The image below gives you a step-by-step visual.
1 Keep Range of Rows
2 Convert to List
3 Reference the table
4 RenameColumns with converted list
The problem is that all headers IS NOT in the same row. Please see my picture at the post, there are some headers in row 1 and some headers in headers as it should be.
- rohit19911 year agoSuper User
Hi Gandhi
If you want to promote a specific row (like the 2nd or 3rd row) as headers in Power Query, open Power Query by clicking Transform Data, then go to the Home tab and click on Advanced Editor. Replace Source with your existing step name and use the formula Table.PromoteHeaders(Table.Skip(Source, 1), [PromoteAllScalars=true]), where the number 1 means it will skip the first row and promote the second row as headers. You can change this number to 2 for the third row, 3 for the fourth, and so on. This method promotes your desired row as headers and removes the rows above it.