Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Use particular row as header

Hi,   Can we use rows which has particular value as Header? instead of first row? As I combined multiple files so if I use first row, then only 1 row from 1 file has header and rest of files have ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    If you are making a change to a row I think you can do it in Power Query by first deleting all the rows above the row you want to use as a title. If there is only the desired row at the top, use the "Use first row as Headers " option to elevate that row to a title.

    In case of multiple columns, I think you can use M-code, the following M-code will hopefully help you.

    let
        Source = Excel.CurrentWorkbook(){[Name="YourTableName"]}[Content],
        PromoteHeaders = Table.PromoteHeaders(
            Table.Skip(Source, 
                List.PositionOf(
                    List.Transform(Source[Column1], Text.Upper), 
                    "ID"
                )
            )
        )
    in
        PromoteHeaders
    

     

     

     

    Best Regards

    Yilong Zhou

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