Table.RenameColumns

Table

Renames one or more columns in a table.

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

Syntax

Table.RenameColumns(table as table, renames as list, optional missingField as nullable number) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe input table whose columns are to be renamed.
renameslistYesA list of rename pairs in the form {oldName, newName}, or a list of such pairs for multiple renames.
missingFieldnumberNoControls behavior when a specified column does not exist. Use MissingField.Error (default), MissingField.Ignore, or MissingField.UseNull.

Return Value

tableA table with the specified columns renamed.

Remarks

Table.RenameColumns returns a new table with the specified columns renamed. The renames parameter accepts a list of two-item lists, where each inner list contains the old column name and the new column name.

To rename a single column, pass {"OldName", "NewName"}. To rename multiple columns, pass a list of pairs like {{"OldName1", "NewName1"}, {"OldName2", "NewName2"}}.

If a specified column does not exist, an error is raised by default. As a best practice, use the optional missingField parameter with MissingField.Ignore to prevent broken refreshes if upstream columns change.

If you have multiple rename steps in your query, consolidate them into a single Table.RenameColumns call with a list of pairs. Multiple separate rename steps add unnecessary overhead and make the query harder to maintain.

Examples

Example 1: Rename a single column

Table.RenameColumns(Sales, {"CustomerName", "Customer"})
Result
OrderID
Customer
Product
Category
UnitPrice
Quantity
OrderDate
Region
11AliceWidget AWidgets2541/15/2024East
22BobGadget BGadgets5021/18/2024West
33CharlieWidget CWidgets15102/1/2024East
44AliceGadget DGadgets7512/10/2024North
55DianaWidget AWidgets2563/5/2024West
66BobThingamajig EMisc12013/12/2024East
77CharlieGadget BGadgets5034/1/2024West
88DianaWidget CWidgets1584/15/2024North

Example 2: Rename multiple columns

Table.RenameColumns(Sales, {{"UnitPrice", "Price"}, {"Quantity", "Qty"}})
Result
OrderID
CustomerName
Product
Category
Price
Qty
OrderDate
Region
11AliceWidget AWidgets2541/15/2024East
22BobGadget BGadgets5021/18/2024West
33CharlieWidget CWidgets15102/1/2024East
44AliceGadget DGadgets7512/10/2024North
55DianaWidget AWidgets2563/5/2024West
66BobThingamajig EMisc12013/12/2024East
77CharlieGadget BGadgets5034/1/2024West
88DianaWidget CWidgets1584/15/2024North

Compatibility

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