Record.SelectFields

Record

Returns a record containing only the specified fields.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Record.SelectFields(record as record, fields as any, optional missingField as nullable number) as record

Parameters

NameTypeRequiredDescription
recordrecordYesThe record to select fields from.
fieldsanyYesA field name or list of field names to keep.
missingFieldnumberNoA 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

recordA 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
1OrderID1
2ProductWidget A
3UnitPrice25

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks