Record.FieldOrDefault is a Power Query M function that returns the value of the specified field in a record or a default value if the field is not found. The function returns the value of the field or the optional defaultValue if the field is not present.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Record.FieldOrDefault(
record as nullable record,
field as text,
optional defaultValue as any,
) as any
Description
Returns the value of the specified field field
in the record record
. If the field is not found, the optional defaultValue
is returned.
Examples
Find the value of field “Phone” in the record, or return null if it doesn’t exist.
// Output: null
Record.FieldOrDefault( [CustomerID = 1, Name = "Bob"], "Phone" )
Find the value of field “Phone” in the record, or return the default if it doesn’t exist.
// Output: "123-4567"
Record.FieldOrDefault( [CustomerID = 1, Name = "Bob"], "Phone", "123-4567" )
Related functions
Other functions related to Record.FieldOrDefault are:
