Table.FromPartitions

Updated on

Table.FromPartitions is a Power Query M function that returns a table resulting from combining a set of partitioned tables. The function returns a combined table with an added partitionColumn.

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

Syntax

Table.FromPartitions(
   partitionColumn as text,
   partitions as list,
   optional partitionColumnType as nullable type,
) as table

Description

Table.FromPartitions combines partitioned tables, partitions, into one table. partitionColumn is added, with type set by partitionColumnType or defaulting to any.

Examples

Find item type from the list {number}.

Table.FromPartitions( 
    "Year",
    {
        {
            1994,
            Table.FromPartitions( 
                "Month",
                {
                    {
                        "Jan",
                        Table.FromPartitions( 
                            "Day",
                            {
                                {1, #table( {"Foo"}, {{"Bar"}} )},
                                {2, #table( {"Foo"}, {{"Bar"}} )}
                            }
                         )
                    },
                    {
                        "Feb",
                        Table.FromPartitions( 
                            "Day",
                            {
                                {3, #table( {"Foo"}, {{"Bar"}} )},
                                {4, #table( {"Foo"}, {{"Bar"}} )}
                            }
                         )
                    }
                }
             )
        }
    }
 )

 /* Output: 
Table.FromRecords( {
    [
        Foo = "Bar",
        Day = 1,
        Month = "Jan",
        Year = 1994
    ],
    [
        Foo = "Bar",
        Day = 2,
        Month = "Jan",
        Year = 1994
    ],
    [
        Foo = "Bar",
        Day = 3,
        Month = "Feb",
        Year = 1994
    ],
    [
        Foo = "Bar",
        Day = 4,
        Month = "Feb",
        Year = 1994
    ]
} )
 */ 

Other functions related to Table.FromPartitions are:

BI Gorilla Youtube Channel

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