Table.ReplacePartitionKey

Table

Replaces the partition key of the specified table.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Table.ReplacePartitionKey(table as table, partitionKey as nullable list) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe table whose partition key to replace.
partitionKeylistNoA list of column names to set as the new partition key, or null to clear the partition key.

Return Value

tableA table with the partition key replaced by the specified column list.

Remarks

Table.ReplacePartitionKey sets or replaces the partition key metadata on a table. The partition key is a list of column names that define how the table's data is logically segmented. Pass null to clear an existing partition key.

This is the setter counterpart to Table.PartitionKey. Partition keys are primarily used by custom connectors and the Power Query engine to enable parallel evaluation of partitioned data sources.

Examples

Example 1: Set a partition key on a table

let
    Partitioned = Table.ReplacePartitionKey(Sales, {"Category"}),
    Key = Table.PartitionKey(Partitioned)
in
    Key

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks