Record.RemoveFields

Updated on

Record.RemoveFields is a Power Query M function that removes specified fields from a record. The function returns a new record without the specified fields, or throws an exception if a field to be removed does not exist.

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

Syntax

Record.RemoveFields(
   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

Record.RemoveFields eliminates specified fields from a record, listed in fields. It effectively trims the record by removing unwanted data. If any listed field is not found in the record, the function will result in an error. Instead of returning an error, you can also specify a MissingField.Type to change its behaviour.

Examples

Remove the field “Price” from the record.

// Output: [CustomerID = 1, Item = "Fishing rod"]
Record.RemoveFields( [CustomerID = 1, Item = "Fishing rod", Price = 18.00], "Price" )

Remove the fields “Price” and “Item” from the record.

// Output: [CustomerID = 1]
Record.RemoveFields( [CustomerID = 1, Item = "Fishing rod", Price = 18.00], {"Price", "Item"} )

Other functions related to Record.RemoveFields are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/record-removefields