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 tableParameters
- 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
| Region | Product | Quantity |
|---|---|---|
| North | Kite | 2 |
| South | Reel | 5 |
| North | Reel | 1 |
| West | Kite | 4 |
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
| CustomerID | Amount |
|---|---|
| 7 | 12.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
- Names are case-sensitive; a missing old name raises an error by default.
Common mistakes
- Renaming to a name another column already has, which raises 'The field already exists'.
- Renaming late in the query, so earlier steps and later steps use different names.
Exercises that use Table.RenameColumns
- beginner~6 minFree
Rename and reorder columns for a finance report (kite shop)
Give columns business-friendly names and put them in the order finance expects.
- beginner~6 minFree
Import a CSV that has no header row (cafes)
The till system writes daily takings without a header line. Name the columns yourself and type them.
- advanced~9 minFree
Rename columns from a mapping table (ledger)
Finance keeps a two-column table of old and new column names. Apply it, ignoring names the export doesn't have.
- intermediate~9 minPro
Append store and web sales with different column names (bookshop)
Align WebSales column names to StoreSales before appending, and see where nulls come from.
- intermediate~12 minPro
Combine every monthly CSV in a folder (kite shop)
Read every file in the folder, keep the file name, and stack the orders into one typed table.
- intermediate~9 minPro
Split a tag list into one row per tag (outdoor shop)
Each product has a semicolon-separated Tags cell. Produce one row per product and tag, trimmed, with no empty tags.
Learn more
- Rename and reorder columns lesson
Related functions
Official documentation: Table.RenameColumns on Microsoft Learn.