Record.SelectFields
RecordReturns a record containing only the specified fields.
Syntax
Record.SelectFields(record as record, fields as any, optional missingField as nullable number) as recordParameters
| Name | Type | Required | Description |
|---|---|---|---|
record | record | Yes | The record to select fields from. |
fields | any | Yes | A field name or list of field names to keep. |
missingField | number | No | A MissingField enum value that controls behavior when a specified field does not exist. Options are MissingField.Error (default), MissingField.Ignore, or MissingField.UseNull. |
Return Value
record — A record with only the specified fields.
Remarks
Record.SelectFields returns a new record containing only the fields you specify. This is the record-level equivalent of Table.SelectColumns. The optional missingField parameter controls what happens when a requested field does not exist in the record: raise an error (default), silently ignore it, or include it with a null value.
Examples
Example 1: Select a few fields from a Sales row
let
Selected = Record.SelectFields(Sales{0}, {"OrderID", "Product", "UnitPrice"})
in
Record.ToTable(Selected)Result
Name | Value | |
|---|---|---|
| 1 | OrderID | 1 |
| 2 | Product | Widget A |
| 3 | UnitPrice | 25 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks