Record.SelectFields
A record with only the fields you name, in the order you name them.
Group: Record. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Record.SelectFields(record as record, fields as any, optional missingField as nullable number) as record
| Parameter | Type | Description |
|---|---|---|
record | record | The record to work on. |
fields | any | A field name, or a list of them. |
missingField | nullable 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 named fields.
Examples
Two fields of an order
Record.SelectFields([Order = 1001, Shop = "Oslo", Total = 120], {"Order", "Total"})
[Order = 1001, Total = 120]
In another order
Record.SelectFields([Order = 1001, Shop = "Oslo", Total = 120], {"Total", "Order"})
[Total = 120, Order = 1001]
A missing field as null
Record.SelectFields([Order = 1001, Shop = "Oslo"], {"Order", "Discount"}, MissingField.UseNull)
[Order = 1001, Discount = null]
Related functions
Record.RemoveFields, Record.ReorderFields, Table.SelectColumns.