Record.SelectFields

Record.SelectFields is a Power Query M function that filters a record to include only the specified fields. The function returns a new record containing only the fields specified in the input list.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Record.SelectFields(
   record as record,
   fields as any,
   optional missingField as nullable number,
) as record
Argument Attribute Description
record
fields
missingField optional The MissingField.Type determines the function’s reaction to operations on missing columns. When omitted, it uses MissingField.Error and generates an error for missing columns. Alternatives include MissingField.UseNull, substituting null for missing columns, and MissingField.Ignore, which ignores missing columns.

Description

Returns a record which includes only the fields specified in list fields from the input record.

Examples

Select the fields “Item” and “Price” in the record.

// Output: [Item = "Fishing rod", Price = 100]
Record.SelectFields( 
    [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],
    {"Item", "Price"}
 )

Other functions related to Record.SelectFields are:

BI Gorilla Youtube Channel

Last update: December 1, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/record-selectfields
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.