Forum Discussion
Reorder columns in Query Editor without listing the column names
- 9 years ago
hi majdkaid22,
You may reorder your columns in power query alphabetically using a custom code.
=Table.ReorderColumns( NameOfPreviousStep, List.Order( Table.ColumnNames( NameOfPreviousStep ), Order.Ascending )
Anonymous - please can you expand with an example?
I have a table with column headers "email", "name", "Address", followed by 3 headers that always change with the dataset - question 1, question 2 and question 3.
When I format the first headers it automatically moves them to the end.
How I can I reorder them back to the order above without explicitly mentioning the question 1-3 headers as these aren't defined -they change everytime.
Know this is old but hope it helps someone:
Where the previous step is Output and the column you want first is "Employee Number"
Reordered= Table.ReorderColumns(Output,List.Combine({{"Employee Number"},List.RemoveItems(Table.ColumnNames(Output),{"Employee Number"})}))