OpenBI Docs Buy

Record.RenameFields

A record with some fields given new names, their values and places kept.

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

Syntax

Record.RenameFields(record as record, renames as list, optional missingField as nullable number) as record
ParameterTypeDescription
recordrecordThe record to work on.
renameslistOne pair {old, new}, or a list of pairs {{old, new}, ...}.
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 names.

Examples

One field

Record.RenameFields([Order = 1001, Shop = "Oslo"], {"Shop", "Store"})
[Order = 1001, Store = "Oslo"]

Several fields

Record.RenameFields([OrderNo = 1001, Shop = "Oslo"], {{"OrderNo", "Order"}, {"Shop", "Store"}})
[Order = 1001, Store = "Oslo"]

A field the record lacks

Record.RenameFields([Order = 1001, Shop = "Oslo"], {"Branch", "Store"}, MissingField.UseNull)
[Order = 1001, Shop = "Oslo", Store = null]

There is no Branch to rename, so Store is added with null; MissingField.Ignore would leave the record as it was.

Record.ReorderFields, Record.TransformFields, Table.RenameColumns.

Last updated · OpenBI Studio 0.3.79