Record.ToList

Updated on

Record.ToList is a Power Query M function that converts a record’s field values into a list. The function returns a list containing the values of all fields in the input record.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Record.ToList( record as record ) as list

Description

Record.ToList extracts the field values of an input record and stores them in a list. This allows you to work with the field values of your record.

Examples

Retrieving All Field Values from a Record

To retrieve all field values from a record, you can use the following code:

// Output: { "Orange", "Strawberry", "Peach" }
Record.ToList( [ Citrus = "Orange", Berry = "Strawberry", StoneFruit = "Peach" ] )

In this example, the Record.ToList function takes a record with three fields: Citrus, Berry, and StoneFruit, each with a unique value. The function retrieves these field values and returns them as a list. This is what it looks like:

Record.ToList retrieves field values from a record in Power Query M

Using Record.FieldValues for the Same Outcome

You can achieve the same result by using the Record.FieldValues function:

// Output: { "Orange", "Strawberry", "Peach" }
Record.FieldValues( [ Citrus = "Orange", Berry = "Strawberry", StoneFruit = "Peach" ] )

Both functions serve the same purpose of converting a record’s field values into a list.

The opposite of this function would be the Record.FieldNames function, which returns all the field names of the record as a list.

Other functions related to Record.ToList are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/record-tolist

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy