Table.ReorderColumns
Table function · By Tahir Nas · Examples run in our simulator · Published · Updated
Puts columns in a new order.
When to use it
Use it when the column order matters to people reading the output or to a tool that loads by position. It doesn't change values, only positions, and it's cheap.
Syntax
Table.ReorderColumns(table as table, columnOrder as list, optional missingField as nullable number) as tableParameters
- columnOrder
- Column names in the new order.
Returns
The table with columns reordered.
Example
Table.ReorderColumns(#table({"Region", "Product", "Qty"}, {{"North", "Kite", 2}, {"South", "Reel", 5}, {"North", "Reel", 1}, {"West", "Kite", 4}}), {"Qty", "Region", "Product"})Result
| Qty | Region | Product |
|---|---|---|
| 2 | North | Kite |
| 5 | South | Reel |
| 1 | North | Reel |
| 4 | West | Kite |
Example: move one column to the front
Listing only the columns you move keeps the step short; the others keep their relative order.
Table.ReorderColumns(#table({"Amount", "Region", "Rep"}, {{120, "North", "Ana"}}), {"Region", "Amount"})Result
| Region | Amount | Rep |
|---|---|---|
| North | 120 | Ana |
Both results are produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M, and checked on every build.
Good to know
- Listing only some columns moves those, keeping the others in their relative positions.
Common mistakes
- Listing a column that a source sometimes lacks, without a MissingField option.
- Reordering by position in generated code, which silently moves the wrong columns after a schema change.
Exercises that use Table.ReorderColumns
- beginner~6 minFree
Rename and reorder columns for a finance report (kite shop)
Give columns business-friendly names and put them in the order finance expects.
- intermediate~7 minFree
Move the key column first and keep the rest in order (it assets)
Put AssetID first. Every other column keeps its current order, including columns added in future exports.
Learn more
- Rename and reorder columns lesson
Related functions
Official documentation: Table.ReorderColumns on Microsoft Learn.