Record.FieldValues Function (Power Query M)

If you want to pull every value out of a record and get them back as a plain list, Record.FieldValues does exactly that. It hands you the values in field order and drops the names.

Syntax of Record.FieldValues Function

Record.FieldValues(record as record) as list

where

  • record (required, record). The record whose field values you want to pull out into a list.

Returns: a list of the field values, in field-definition order. An empty record [] returns an empty list {}.

A record is a set of name=value pairs. Record.FieldValues keeps the values and throws away the names, so you go from a record to a list you can sort, sum, or join. Records show up a lot when you parse data with Json.Document, so this is a handy next step.

Example 1: Get all values from a record

Say you have a small order record and you just want its values as a list.

let
Source = Record.FieldValues([OrderId=1001,Status="Open",Total=250])
in
Source

Result: {1001, “Open”, 250}

The list keeps the same order the fields were written in. The names OrderId, Status, and Total are gone.

Example 2: Mixed types stay intact

The values keep their original types. Numbers stay numbers, text stays text, and a logical stays a logical.

let
Source = Record.FieldValues([Product="Laptop Stand",UnitPrice=24.95,InStock=true,Quantity=40])
in
Source

Result: {“Laptop Stand”, 24.95, true, 40}

You get a mixed-type list here. The order matches the order the fields appear in the record, left to right.

Example 3: Sum the values of a record

Turn a record into a list and feed it straight into a list function. Here the monthly figures get added up.

let
Source = List.Sum(Record.FieldValues([Jan=1200,Feb=1450,Mar=1380]))
in
Source

Result: 4030

Record.FieldValues gives List.Sum a list of numbers, so you skip pulling each field out by hand. You could just as easily run List.Transform over the same list to reshape each value.

Example 4: Join record values into one string

You can combine the values into a single piece of text. This pulls the address parts and glues them together.

let
Source = Text.Combine(Record.FieldValues([City="Austin",State="TX",Zip="78701"]),", ")
in
Source

Result: Austin, TX, 78701

Record.FieldValues returns the three text values, then Text.Combine joins them with a comma and a space.

Things to keep in mind with Record.FieldValues

  • It returns a list, not a record. The field names are dropped. If you need the names too, call Record.FieldNames separately.
  • Order is the field-definition order, not alphabetical. Whatever order the fields sit in the record is the order you get back.
  • For one field’s value, don’t use this. Use record[FieldName], like [OrderId=1001][OrderId], which returns 1001. The Record.Field function does the same thing when the field name is text.
  • It stays position-aligned with Record.FieldNames. Same order, same count, so you can zip the two lists back into name/value pairs.
  • An empty record [] returns an empty list {}, not an error.
  • Record.ToList is an exact synonym, so you may see either one in other people’s code.

Common questions about Record.FieldValues

What’s the difference between Record.FieldValues and Record.FieldNames?

Record.FieldValues returns the values, Record.FieldNames returns the names. Both come back in the same order and the same count, so index 0 of one lines up with index 0 of the other.

How do I get just one field’s value?

You don’t need Record.FieldValues for that. Use field access with record[FieldName]. For example, [City="Austin",State="TX"][State] returns "TX".

List of All Power Query Functions

Related Power Query Functions / Articles:

I am a huge fan of Microsoft Excel and love sharing my knowledge through articles and tutorials. I work as a business analyst and use Microsoft Excel extensively in my daily tasks. My aim is to help you unleash the full potential of Excel and become a data-slaying wizard yourself.