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
| Parameter | Type | Description |
|---|---|---|
table | table | The table whose columns to rename. |
renames | list | One pair {old, new}, or a list of pairs. |
missingField | nullable 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"}})
| Product | Amount |
|---|---|
| Chair | 50 |
A column that may not be there
Table.RenameColumns(#table({"prod", "amt"}, {{"Chair", 50}}), {{"prod", "Product"}, {"qty", "Units"}}, MissingField.Ignore)
| Product | amt |
|---|---|
| Chair | 50 |
Related functions
Table.TransformColumnNames, Table.PrefixColumns, Table.ColumnNames.