Power QueryExercises

Table.AddColumn

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

Adds a column calculated from each row.

When to use it

Use it for any value calculated from the row: totals, flags, categories, keys. Always pass the type argument so the new column isn't typed as any. For changing an existing column, Table.TransformColumns avoids a helper column.

Syntax

Table.AddColumn(table as table, newColumnName as text, columnGenerator as function, optional columnType as nullable type) as table

Parameters

columnGenerator
A function of the row, usually written with each.
columnType
Optional type for the new column, such as type number.

Returns

The table with the new column at the end.

Example

Table.AddColumn(#table({"Region", "Product", "Qty"}, {{"North", "Kite", 2}, {"South", "Reel", 5}, {"North", "Reel", 1}, {"West", "Kite", 4}}), "Double", each [Qty] * 2, type number)

Result

RegionProductQtyDouble
NorthKite24
SouthReel510
NorthReel12
WestKite48

Example: a conditional category

if … then … else inside each gives each row its own result.

Table.AddColumn(#table({"Region", "Rep", "Amount"}, {{"North", "Ana", 120}, {"South", "Bo", 80}, {"North", "Cy", 200}, {"South", "Ana", 50}}), "Size", each if [Amount] >= 100 then "Large" else "Small", type text)

Result

RegionRepAmountSize
NorthAna120Large
SouthBo80Small
NorthCy200Large
SouthAna50Small

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

The matching command in Excel

Excel for Windows
Add Column > Custom Column
What you see
You type the formula for one row and the column is calculated for every row.

Paths are for the Power Query editor in Excel for Microsoft 365, checked against Microsoft's documentation on 8 November 2026: Add a custom column (Microsoft Learn).

Exercises that use Table.AddColumn

Learn more

Related functions

Official documentation: Table.AddColumn on Microsoft Learn.