Table.ReorderColumns

Table

Reorders columns in a table to a specified order.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Table.ReorderColumns(table as table, columnOrder as list, optional missingField as nullable number) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe input table whose columns to reorder.
columnOrderlistYesA list of column names specifying the desired order. Columns not listed retain their relative order after the listed ones.
missingFieldnumberNoControls behavior when a listed column doesn't exist. Use MissingField.Error (default), MissingField.Ignore, or MissingField.UseNull.

Return Value

tableA table with columns rearranged in the specified order.

Remarks

Table.ReorderColumns changes the column order without adding or removing columns. You only need to list the columns whose position you want to control — any unlisted columns keep their original relative order and appear after the listed ones.

Use MissingField.Ignore when working with tables whose columns may vary, to avoid runtime errors if a column in your list doesn't exist.

Examples

Example 1: Move Product and Category to the front

Table.SelectColumns(
    Table.ReorderColumns(Table.FirstN(Sales, 3), {"Product", "Category"}),
    {"Product", "Category", "OrderID", "CustomerName"}
)
Result
Product
Category
OrderID
CustomerName
1Widget AWidgets1Alice
2Gadget BGadgets2Bob
3Widget CWidgets3Charlie

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks