OpenBI Docs Buy

Table.RenameColumns

Gives columns new names, from pairs of old name and new name.

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

Syntax

Table.RenameColumns(table as table, renames as list, optional missingField as nullable number) as table
ParameterTypeDescription
tabletableThe table whose columns to rename.
renameslistOne pair {old, new}, or a list of pairs.
missingFieldnullable number
optional
What to do when an old name isn't a column: MissingField.Error (the default), MissingField.Ignore (skip the pair) or MissingField.UseNull (add the new name as a column of nulls).

Returns

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

Remarks

  • A new name that another column already has is an error.
  • Names are case-sensitive: the pair {"product", "Item"} doesn't find a column called Product.

Examples

Two columns renamed

Table.RenameColumns(#table({"prod", "amt"}, {{"Chair", 50}}), {{"prod", "Product"}, {"amt", "Amount"}})
ProductAmount
Chair50

A column that may not be there

Table.RenameColumns(#table({"prod", "amt"}, {{"Chair", 50}}), {{"prod", "Product"}, {"qty", "Units"}}, MissingField.Ignore)
Productamt
Chair50

Table.TransformColumnNames, Table.PrefixColumns, Table.ColumnNames.

Last updated · OpenBI Studio 0.3.79