Table.TransformRows
TableApplies a transform function to each row (as a record) and returns a list of the results.
Syntax
Table.TransformRows(table as table, transform as function) as listParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The table to iterate over. |
transform | function | Yes | A function that accepts a row as a record and returns a value. |
Return Value
list — A list where each element is the result of applying the transform function to a row record.
Remarks
Table.TransformRows iterates over every row of a table as a record and applies a transform function, returning the results as a flat list. Unlike Table.AddColumn (which adds a computed value back as a new column in a table), Table.TransformRows produces a list of arbitrary M values — scalars, records, lists, or any other type. The output is a list, not a table.
This makes Table.TransformRows a more powerful but lower-level operation than Table.AddColumn or Table.TransformColumns. It is primarily used when you need to reshape entire rows into a completely different structure — for example, converting rows into JSON-like records for an API call, or building a list of custom objects from tabular data.
When you want to produce a table (not a list) from a per-row transformation, wrap the result in Table.FromRecords(Table.TransformRows(...)). For most per-row calculations that stay within the table structure, Table.AddColumn is simpler and more readable.
Examples
Example 1: Build formatted label strings from each Sales row
let
Sales = #table(
{"OrderID","CustomerName","Product","UnitPrice","Quantity"},
{{1,"Alice","Widget A",25.00,4},{2,"Bob","Gadget B",50.00,2},{3,"Charlie","Widget C",15.00,10}}
)
in
Table.TransformRows(
Sales,
each "Order #" & Text.From([OrderID]) & ": " & [CustomerName] & " — " & [Product] & " x" & Text.From([Quantity])
)Result | |
|---|---|
| 1 | {"Order #1: Alice — Widget A x4", "Order #2: Bob — Gadget B x2", "Order #3: Charlie — Widget C x10"} |
Example 2: Compute derived records including Revenue per row
let
Sales = #table(
{"OrderID","CustomerName","Product","UnitPrice","Quantity"},
{{1,"Alice","Widget A",25.00,4},{2,"Bob","Gadget B",50.00,2},{6,"Bob","Thingamajig E",120.00,1}}
),
Enriched = Table.TransformRows(
Sales,
each [OrderID = [OrderID], CustomerName = [CustomerName], Product = [Product],
UnitPrice = [UnitPrice], Quantity = [Quantity], Revenue = [UnitPrice] * [Quantity]]
)
in
Table.FromRecords(Enriched)OrderID | CustomerName | Product | UnitPrice | Quantity | Revenue | |
|---|---|---|---|---|---|---|
| 1 | 1 | Alice | Widget A | 25 | 4 | 100 |
| 2 | 2 | Bob | Gadget B | 50 | 2 | 100 |
| 3 | 6 | Bob | Thingamajig E | 120 | 1 | 120 |
Example 3: Extract a specific field from each row as a list
let
Employees = #table(
type table [EmployeeID = text, FullName = text, Department = text, Salary = number],
{{"E001","alice smith","Sales",55000},{"E002","BOB JONES","Engineering",95000},
{"E003","Charlie Brown","Marketing",72000},{"E005","Eve Martinez","Sales",88000}}
)
in
Table.TransformRows(Employees, each [FullName] & " (" & [Department] & ")")Result | |
|---|---|
| 1 | {"alice smith (Sales)", "BOB JONES (Engineering)", "Charlie Brown (Marketing)", "Eve Martinez (Sales)"} |