Record.FieldOrDefault

This function retrieves the value of a specific field within a given record. If the field is not found, the defaultValue parameter is returned as an optional fallback option.

Syntax

Record.FieldOrDefault(record as nullable record, field as text, optional defaultValue as any) as any

About

This function retrieves the value of a specific field within a given record. If the field is not found, the defaultValue parameter is returned as an optional fallback option.

Explanation

Identify the value of the field "Phone" in the record. If the field does not exist, return a null value. Instructions: Power Query MRecord.FieldOrDefault([CustomerID = 1, Name = "Bob"], "Phone") Result: null Identify the value of the field "Phone" in the record. If the field does not exist, return a default value. Instructions: Power Query MRecord.FieldOrDefault([CustomerID = 1, Name = "Bob"], "Phone", "123-4567") Result: "123-4567"