Record.TransformFields
RecordApplies transformation functions to specified fields in a record, returning a new record with the transformed values.
Syntax
Record.TransformFields(record as record, transformOperations as list, optional missingField as nullable number) as recordParameters
| Name | Type | Required | Description |
|---|---|---|---|
record | record | Yes | The source record. |
transformOperations | list | Yes | A list of transformation operations. Each element is a two-item list {fieldName, transformFunction} or a three-item list {fieldName, transformFunction, newFieldName}. |
missingField | number | No | Controls behavior when a specified field does not exist: MissingField.Error (default), MissingField.Ignore, or MissingField.UseNull. |
Return Value
record — A new record with the specified fields transformed.
Remarks
Record.TransformFields applies transformation functions to specified fields in a record and returns a new record with the results. Each item in the transformOperations list describes one transformation:
- {fieldName, function} — a two-element list that applies function to the named field in place, keeping the same field name
- {fieldName, function, newFieldName} — a three-element list that applies function to the named field and renames it to newFieldName
The transform function receives the current field value and must return the new value. Fields not listed in transformOperations are passed through unchanged. All transformations are applied to the original record — they are not chained sequentially — so the order of operations within the list does not matter.
Record.TransformFields is the record-level equivalent of Table.TransformColumns. Use it when you need to modify one or more field values within a record without constructing a new record literal manually. The optional missingField parameter controls behavior when a listed field does not exist: MissingField.Error (default, raises an error), MissingField.Ignore (skips the operation silently), or MissingField.UseNull (applies the function to null).
A common pattern is to use this function in Table.TransformRows or inside each expressions to normalize record fields while processing rows from a table.
Examples
Example 1: Uppercase a text field in a record
Record.TransformFields(
[Name = "alice", Age = 30],
{{"Name", Text.Upper}}
)Name | Age | |
|---|---|---|
| 1 | ALICE | 30 |
Example 2: Transform multiple fields at once
Record.TransformFields(
[Name = "bob", Age = 25.7, City = "seattle"],
{
{"Name", Text.Proper},
{"Age", Number.RoundDown},
{"City", Text.Proper}
}
)Name | Age | City | |
|---|---|---|---|
| 1 | Bob | 25 | Seattle |
Example 3: Transform and rename a field using Sales data
let
Row = Sales{0},
Transformed = Record.TransformFields(
Row,
{{"UnitPrice", each _ * Row[Quantity], "LineTotal"}}
)
in
Record.SelectFields(Transformed, {"OrderID", "CustomerName", "LineTotal"})The final output — selects only OrderID, CustomerName, and LineTotal from the transformed record.
OrderID | CustomerName | LineTotal | |
|---|---|---|---|
| 1 | 1 | Alice | 100 |