Table.ReorderColumns
TableReorders columns in a table to a specified order.
Syntax
Table.ReorderColumns(table as table, columnOrder as list, optional missingField as nullable number) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The input table whose columns to reorder. |
columnOrder | list | Yes | A list of column names specifying the desired order. Columns not listed retain their relative order after the listed ones. |
missingField | number | No | Controls behavior when a listed column doesn't exist. Use MissingField.Error (default), MissingField.Ignore, or MissingField.UseNull. |
Return Value
table — A 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 | |
|---|---|---|---|---|
| 1 | Widget A | Widgets | 1 | Alice |
| 2 | Gadget B | Gadgets | 2 | Bob |
| 3 | Widget C | Widgets | 3 | Charlie |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks