Record.FromList
RecordCreates a record from a list of values and a set of field names.
Syntax
Record.FromList(list as list, fields as any) as recordParameters
| Name | Type | Required | Description |
|---|---|---|---|
list | list | Yes | A list of values to use as the field values. |
fields | any | Yes | A list of field names, or a record type that defines the field names and types. |
Return Value
record — A 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 | |
|---|---|---|
| 1 | OrderID | 1 |
| 2 | CustomerName | Alice |
| 3 | Product | Widget A |
| 4 | Category | Widgets |
| 5 | UnitPrice | 25 |
| 6 | Quantity | 4 |
| 7 | OrderDate | 2024-01-15 |
| 8 | Region | East |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks