OpenBI Docs Buy

Record.ReorderFields

A record with the fields you name put in the order you give.

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

Syntax

Record.ReorderFields(record as record, fieldOrder as list, optional missingField as nullable number) as record
ParameterTypeDescription
recordrecordThe record to work on.
fieldOrderlistThe field names in their new order.
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 same fields and values in the new order.

Examples

Every field named

Record.ReorderFields([Total = 120, Shop = "Oslo", Order = 1001], {"Order", "Shop", "Total"})
[Order = 1001, Shop = "Oslo", Total = 120]

Two fields swapped

Record.ReorderFields([Shop = "Oslo", Order = 1001, Total = 120], {"Order", "Shop"})
[Order = 1001, Shop = "Oslo", Total = 120]

Total, not in the list, keeps its place at the end.

A field the record lacks, added

Record.ReorderFields([Order = 1001, Shop = "Oslo"], {"Shop", "Order", "Note"}, MissingField.UseNull)
[Shop = "Oslo", Order = 1001, Note = null]

Record.SelectFields, Record.RenameFields, Table.ReorderColumns.

Last updated · OpenBI Studio 0.3.79