Re-ordering columns
Moving a column by dragging it in the Power Query Editor writes a Table.ReorderColumns step that names every column in the table. That is convenient, but it makes the query fragile, because the step fails on refresh as soon as any of those columns is renamed or removed in the source.
Two habits reduce the risk:
- Reorder only after removing the columns the report does not need, so that fewer names are involved.
- Name only the columns whose position matters, and let the others keep their order.
This page shows how to do the second.
The example
Section titled “The example”The data has six columns:

The aim is to make City and Revenue the second and third columns, while leaving the order of the rest alone.
1. Load the data into Power Query
Section titled “1. Load the data into Power Query”
2. Add a step written in M
Section titled “2. Add a step written in M”Click the fx button beside the formula bar to add a step, and enter this formula:
= Table.ReorderColumns( Source, List.InsertRange( List.Difference( Table.ColumnNames(Source), {"City", "Revenue"} ), 1, {"City", "Revenue"} ) )The formula builds the new column order as a list, in two stages:
List.Differencetakes the table’s column names and removes City and Revenue, which leaves {Date, Color, Supplier, Category}.List.InsertRangeputs City and Revenue back into that list at position 1, which is the second place, because positions count from 0.
The result is {Date, City, Revenue, Color, Supplier, Category}, and Table.ReorderColumns arranges the table in that order. Only City and Revenue are named, so the step keeps working if the other columns change.
The technique on this page follows one in Gil Raviv’s Collect, Combine, and Transform Data Using Power Query in Excel and Power BI (Microsoft Press).