Record.HasFields

Updated on

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

Record.HasFields examines a record to confirm the presence of specified fields, indicated by fields. The outcome is a boolean value that signifies whether all queried fields exist within the record.

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:

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