Table.FromRecords

Updated on

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
Argument Attribute Description
records
columns optional
missingField optional The MissingField.Type determines the function’s reaction to operations on missing columns. When omitted, it uses MissingField.Error and generates an error for missing columns. Alternatives include MissingField.UseNull, substituting null for missing columns, and MissingField.Ignore, which ignores missing columns.

Description

Table.FromRecords transforms a list of records, records, into a table, where each record becomes a table row.

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}
 )

Learn more about Table.FromRecords in the following articles:

Other functions related to Table.FromRecords are:

BI Gorilla Blog

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