Forum Discussion
DanFromMontreal
4 years agoHelper IV
Reordering 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
DanFromMontreal
4 years agoHelper IV
Vijay_A_Verma , worked almost like a charm.
If the column "Qty" was NOT present, I get an error. Any way to overcome this without having to manually add the column?
Also, I noticed that you do not reference to the column "Column" to get the ordering. I therefore assume that it is irrelevant and the order is set by where the column name is in the list.
Anonymous
4 years agoNot applicable
DanFromMontreal wrote:
Vijay_A_Verma , worked almost like a charm.
If the column "Qty" was NOT present, I get an error. Any way to overcome this without having to manually add the column?
the solution I proposed should solve the problem of the missing columnS.
Have you tried it?