Record.RemoveFields

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

Returns a record that removes all the fields specified in list fields from the input record. If the field specified does not exist, an exception is thrown.

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:

BI Gorilla Blog

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