Record.FieldValues
Returns the values of all the fields in a record, as a list.
Record.FieldValues(record)Returns: A list of the field values, in the same order as Record.FieldNames.
What it does
Record.FieldValues gives you the values of a record as a plain list, without the names. Use it to total a row, to check that all the amounts in one row add up to a control figure, or to pass a row's values to a list function.
Syntax and arguments
record: the record whose values you want.
Example
A journal line has debit and credit columns for three accounts in one row, and the reviewer wants to test that the amounts net to zero.
let
JournalRow = [CashDebit = 500, SalesCredit = -300, TaxCredit = -200],
Values = Record.FieldValues(JournalRow),
Net = List.Sum(Values)
in
Net
Values is {500, -300, -200}, and Net is 0, so the line balances. A nonzero result would point to a line that needs review.
Example: a second, different use
Checking that no field in a row is blank: List.AnyTrue(List.Transform(Record.FieldValues(Row), each _ = null)).
Things to watch
- The order of the values matches Record.FieldNames. Use them together if you need both names and values.
- Nulls are values too. Remove them with List.RemoveNulls before a total if you do not want them.
- Values of different types can make a list that is hard to total. Convert the fields first.
- To run this on every row of a table, use Table.AddColumn with
each List.Sum(Record.FieldValues(_)).
In business terms
Journal balance checks, row totals in a wide layout and cross-checks of a row against a control figure all use the values of a record. A net of zero is a simple sign that a debit and credit set balances.