Record.FromList

Record

Creates a record from a list of values and a set of field names.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Record.FromList(list as list, fields as any) as record

Parameters

NameTypeRequiredDescription
listlistYesA list of values to use as the field values.
fieldsanyYesA list of field names, or a record type that defines the field names and types.

Return Value

recordA record whose fields correspond to the provided names and values.

Remarks

Record.FromList constructs a record by pairing a list of values with a corresponding list of field names. The values list and the field names list must have the same number of items. The fields parameter can be either a simple list of text names or a record type that also specifies the data type for each field. This function is useful for dynamically building records from column names and values extracted at runtime.

Examples

Example 1: Create a record from column names and values

let
    Names = Table.ColumnNames(Sales),
    Values = Record.FieldValues(Sales{0}),
    NewRecord = Record.FromList(Values, Names)
in
    Record.ToTable(NewRecord)
Result
Name
Value
1OrderID1
2CustomerNameAlice
3ProductWidget A
4CategoryWidgets
5UnitPrice25
6Quantity4
7OrderDate2024-01-15
8RegionEast

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks