Downloads
Power Query MRecordIntermediate

Record.HasFields

Returns true if a record contains all of the fields you name.

Syntax
Record.HasFields(record, fields)

Returns: A logical value, true or false.

What it does

Record.HasFields tests whether a record has the fields you need. Use it before reading a field that might not be there, for example when two exports have slightly different layouts. It returns true only if every named field is present.

Syntax and arguments

Example

A function reads a bank row. Some exports include a Currency field and some do not. The function uses the currency only when it is present.

let
    Row = [Date = #date(2026, 3, 31), Amount = 1250],
    HasCurrency = Record.HasFields(Row, "Currency"),
    Currency = if HasCurrency then Row[Currency] else "USD"
in
    Currency

HasCurrency is false for this row, so the default "USD" is used. The query does not fail on the missing field.

Example: a second, different use

Checking that a row carries all the fields a journal import needs: Record.HasFields(Row, {"Date", "Account", "Amount"}) returns true only if all three are present.

Things to watch

In business terms

Layout checks on monthly and system exports help catch a changed file before the numbers go wrong. A check that stops the refresh with a clear message is better than a total that is silently short.

Related functions

All Power Query M functions · View as Markdown · M basics