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
Table.RenameColumns applies renames of the form {old, new}. It renames columns in table as per renames list. Errors are raised for non-existent columns unless missingField specifies otherwise.
Examples
Replace the column name “CustomerNum” with “CustomerID” in the table.