Table.FromRecords is a Power Query M function that converts a list of records into a table. The function returns a table composed of the input records.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Table.FromRecords(
records as list,
optional columns as any,
optional missingField as nullable number,
) as table
Description
Converts records
, a list of records, into a table.
Examples
Create a table from records, using record field names as column names.
Table.FromRecords( {
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
} )
/* Output:
Table.FromRecords( {
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
} )
*/
Create a table from records with typed columns and select the number columns.
// Output: {"CustomerID"}
Table.ColumnsOfType(
Table.FromRecords(
{[CustomerID = 1, Name = "Bob"]},
type table[CustomerID = Number.Type, Name = Text.Type]
),
{type number}
)
Related articles
Learn more about Table.FromRecords in the following articles:
- Create Tables from Scratch in Power Query M (40+ Examples)
Creating tables from scratch in Power Query can be tricky, but this post shows you how. You learn how to work with lists, records and much more! » Read more
Related functions
Other functions related to Table.FromRecords are:
