Table.RenameColumns is a Power Query M function that renames columns in a table according to a given list of old and new column names. The function returns a new table with the columns renamed, handling missing columns based on an optional parameter.
Compatible with: Power BI ServicePower BI DesktopExcel Microsoft 365
Syntax
Table.RenameColumns(
table as table,
renames as list,
optional missingField as nullable number,
) as table
Argument
Attribute
Description
table
renames
missingField
optional
The MissingField.Type determines the function’s reaction to operations on missing columns. When omitted, it uses MissingField.Error and generates an error for missing columns. Alternatives include MissingField.UseNull, substituting null for missing columns, and MissingField.Ignore, which ignores missing columns.
Description
Performs the given renames to the columns in table table. A replacement operation renames consists of a list of two values, the old column name and new column name, provided in a list.
If the column doesn’t exist, an exception is thrown unless the optional parameter missingField specifies an alternative (eg. MissingField.UseNull or MissingField.Ignore).
Examples
Replace the column name “CustomerNum” with “CustomerID” in the table.