OpenBI Docs Buy

Table.ReorderColumns

Puts the columns in the order you list them.

Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Table.ReorderColumns(table as table, columnOrder as list, optional missingField as nullable number) as table
ParameterTypeDescription
tabletableThe table whose columns to reorder.
columnOrderlistColumn names in the order you want.
missingFieldnullable number
optional
What to do with a name that isn't a column: MissingField.Error (the default), MissingField.Ignore (leave it out) or MissingField.UseNull (add it as a column of nulls, in its place).

Returns

table. The same columns and rows, in the new column order.

Remarks

  • Transform data writes the whole list of columns when you drag one. A column left out of the list is kept, not removed.

Examples

A new order for every column

Table.ReorderColumns(#table({"Price", "Product", "Shop"}, {{50, "Chair", "Oslo"}}), {"Shop", "Product", "Price"})
ShopProductPrice
OsloChair50

Two neighbours swapped

Table.ReorderColumns(#table({"Product", "Price", "Shop"}, {{"Chair", 50, "Oslo"}}), {"Shop", "Price"})
ProductShopPrice
ChairOslo50

A column that may not be there yet

Table.ReorderColumns(#table({"Product", "Price"}, {{"Chair", 50}}), {"Shop", "Price", "Product"}, MissingField.UseNull)
ShopPriceProduct
null50Chair

Table.SelectColumns, Table.ColumnNames, Table.RenameColumns.

Last updated · OpenBI Studio 0.3.79