Power QueryExercises

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 table

Parameters

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

QtyRegionProduct
2NorthKite
5SouthReel
1NorthReel
4WestKite

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

RegionAmountRep
North120Ana

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

Common mistakes

Exercises that use Table.ReorderColumns

Learn more

Related functions

Official documentation: Table.ReorderColumns on Microsoft Learn.