Record.HasFields

Record.HasFields is a Power Query M function that checks if a record has the specified fields and returns a logical value (true or false). The function returns true if all the specified fields are present in the input record, otherwise false.

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

Syntax

Record.HasFields(
   record as record,
   fields as any,
) as logical

Description

Indicates whether the record record has the fields specified in fields, by returning a logical value (true or false). Multiple field values can be specified using a list.

Examples

Check if the record has the field “CustomerID”.

// Output: true
Record.HasFields( [CustomerID = 1, Name = "Bob", Phone = "123-4567"], "CustomerID" )

Check if the record has the field “CustomerID” and “Address”.

// Output: false
Record.HasFields( [CustomerID = 1, Name = "Bob", Phone = "123-4567"], {"CustomerID", "Address"} )

Other functions related to Record.HasFields are:

BI Gorilla Youtube Channel

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