Table.FromRows

Updated on

Table.FromRows is a Power Query M function that creates a table from a list of rows, where each element of the list is an inner list containing column values for a single row. The function returns a table with the specified rows and columns.

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

Syntax

Table.FromRows(
   rows as list,
   optional columns as any,
) as table

Description

Table.FromRows creates a table from a list, rows, where each list element is a row. Optional parameters for columns, table type, or number of columns can be provided.

Examples

Return a table with column [CustomerID] with values {1, 2}, column [Name] with values {“Bob”, “Jim”}, and column [Phone] with values {“123-4567”, “987-6543”}.

Table.FromRows( 
    {
        {1, "Bob", "123-4567"},
        {2, "Jim", "987-6543"}
    },
    {"CustomerID", "Name", "Phone"}
 )

 /* Output: 
Table.FromRecords( {
    [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
    [CustomerID = 2, Name = "Jim", Phone = "987-6543"]
} )
 */ 

Return a table with column [CustomerID] with values {1, 2}, column [Name] with values {“Bob”, “Jim”}, and column [Phone] with values {“123-4567”, “987-6543”}, where [CustomerID] is number type, and [Name] and [Phone] are text types.

Table.FromRows( 
    {
        {1, "Bob", "123-4567"},
        {2, "Jim", "987-6543"}
    },
    type table [CustomerID = number, Name = text, Phone = text]
 )

 /* Output: 
Table.FromRecords( {
    [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
    [CustomerID = 2, Name = "Jim", Phone = "987-6543"]
} )
 */ 

Learn more about Table.FromRows in the following articles:

Other functions related to Table.FromRows are:

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