Power QueryExercises

Table.RenameColumns

Table function · By Tahir Nas · Examples run in our simulator · Published · Updated

Renames columns from a list of {old, new} pairs.

When to use it

Use it to give columns clear, stable names early in a query, so every later step and every report field refers to the same names. For rules that apply to all columns (trim, case), Table.TransformColumnNames is shorter.

Syntax

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

Parameters

renames
A list of {oldName, newName} pairs.

Returns

The table with renamed columns.

Example

Table.RenameColumns(#table({"Region", "Product", "Qty"}, {{"North", "Kite", 2}, {"South", "Reel", 5}, {"North", "Reel", 1}, {"West", "Kite", 4}}), {{"Qty", "Quantity"}})

Result

RegionProductQuantity
NorthKite2
SouthReel5
NorthReel1
WestKite4

Example: rename several columns at once

One step with a list of pairs is easier to review than a chain of single renames.

Table.RenameColumns(#table({"cust_id", "amt"}, {{7, 12.5}}), {{"cust_id", "CustomerID"}, {"amt", "Amount"}})

Result

CustomerIDAmount
712.5

Both results are produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M, and checked on every build.

Good to know

Common mistakes

Exercises that use Table.RenameColumns

Learn more

Related functions

Official documentation: Table.RenameColumns on Microsoft Learn.