OpenBI Docs Buy

Record.TransformFields

A record with some fields' values changed by functions you give, one function per field.

Group: Record. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Record.TransformFields(record as record, transformOperations as list, optional missingField as nullable number) as record
ParameterTypeDescription
recordrecordThe record to work on.
transformOperationslistOne pair {name, function}, or a list of pairs {{name, function}, ...}; each function gets the field's value and gives the new one.
missingFieldnullable number
optional
What to do with a field name the record doesn't have: MissingField.Error (the default), MissingField.Ignore (skip it) or MissingField.UseNull (add it as a field of null).

Returns

record. The record with the new values; names and order are kept.

Examples

A price with 25 % VAT

Record.TransformFields([Product = "chair", Price = 40], {"Price", each _ * 1.25})
[Product = "chair", Price = 50]

Two fields

Record.TransformFields([Product = "chair", Price = 40], {{"Product", Text.Proper}, {"Price", each _ * 1.25}})
[Product = "Chair", Price = 50]

A field that may be missing

Record.TransformFields([Product = "chair", Price = 40], {{"Price", each _ * 1.25}, {"Discount", each _ / 2}}, MissingField.Ignore)
[Product = "chair", Price = 50]

With MissingField.UseNull the record would get Discount too, its function given null.

Record.AddField, Record.RenameFields, Table.TransformColumns.

Last updated · OpenBI Studio 0.3.79