Forum Discussion

stephchnva's avatar
stephchnva
Frequent Visitor
1 year ago
Solved

How do I promote headers except one column?

Hello everyone,    I need your help. I'm connecting my sharepoint to power bi, when I merged the file the headers turned out like this. How can I promote headers except Source.Name which is alread...
  • ronrsnfld's avatar
    1 year ago

    You could insert this code snippet after the step that creates your example table.

    The code removes the first entry from all except the first column, and renames columns 2..n according to the entry in the first row.

    //Promote headers except for first column
        #"Promote Headers2" = 
            let 
                colHdrs = {Table.ColumnNames(#"Previous Step"){0}} & List.Skip(Record.FieldValues(#"Previous Step"{0})),
                colDataRaw = List.Buffer(Table.ToColumns(#"Previous Step")),
                colData = {colDataRaw{0}} & List.Transform(List.Skip(colDataRaw), each List.Skip(_))
            in 
                Table.FromColumns(colData,colHdrs)
    
    
    in
        #"Promote Headers2"

    You should then set the appropriate data types for each column, and may possibly need to clean up the last row.