Forum Discussion
stephchnva
1 year agoFrequent Visitor
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...
- 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.
Omid_Motamedise
1 year agoSuper User
if your table names is Source, use this formula.
= Table.RenameColumns(Source,List.Skip(List.Zip({Table.ColumnNames(Source),Record.ToList(Source{0})})))
in the next step remove the first row