Forum Discussion
DanFromMontreal
Helper IV
4 years agoReordering column using a use define table
Hello dear Power query community, When I'm importing data from a CSV file and my 6 column header name are sequenced as shown in E3:J3 My final output should be like E5:J5 I have rearrange my colu...
- 4 years ago
Yes, that column is redundant. Use this.
= Table.ReorderColumns(Source,List.Select(tblHeaderSequence[Header], (i)=> List.Contains(Table.ColumnNames(Source),i))&List.Difference(Table.ColumnNames(Source),tblHeaderSequence[Header])) - 4 years ago
Great stuff.
Simple and to the point.
Many thanks
Anonymous
4 years agoNot applicable
let
Source = Table.FromRecords({[CustomerID = 1, Phone = "123-4567", Name = "Bob"]}),
colnames=Table.ColumnNames(Source),
neworder={"Phone", "Name"},
rest=List.Difference(colnames, neworder),
trc = Table.ReorderColumns(Source, neworder&{"qty"}&rest, MissingField.UseNull)
in
trcDanFromMontreal
Helper IV
4 years agoAnonymous , thank you for your response but Vijay's solution meet all requirement.
His code made reference to my tblHeaderSequence and was applicable immediately, regardless of which column his missing.