OpenBI Docs Buy

Record.Field

The value of a record's field by its name, a name that may be worked out in the query.

Group: Record. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Record.Field(record as record, field as text) as any
ParameterTypeDescription
recordrecordThe record to work on.
fieldtextThe field's name.

Returns

any. The field's value; an error when the record has no such field.

Remarks

  • Record.Field(r, "Shop") is the same as r[Shop]; the function is for names held in a variable or a column.
  • For a field that may be missing, Record.FieldOrDefault gives a value of your choice instead of an error.

Examples

A field by name

Record.Field([Order = 1001, Shop = "Oslo"], "Shop")
"Oslo"

A name chosen in the query

let
    Order = [Order = 1001, Jan = 120, Feb = 90],
    Month = "Feb"
in
    Record.Field(Order, Month)
90

A missing field

Record.Field([Order = 1001, Shop = "Oslo"], "Discount")

Result: an error.

[Reason = "Expression.Error", Message = "The field 'Discount' of the record wasn't found.", Detail = null]

Record.FieldOrDefault, Record.HasFields, Record.SelectFields.

Last updated · OpenBI Studio 0.3.79