Type.TablePartitionKey

Type

Returns the partition key for the given table type, if one is defined.

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

Syntax

Type.TablePartitionKey(tableType as type) as nullable list

Parameters

NameTypeRequiredDescription
tableTypetypeYesThe table type whose partition key to retrieve.

Return Value

listA list of column names that form the partition key of the table type, or null if no partition key is defined.

Remarks

Type.TablePartitionKey returns the partition key metadata attached to a table type as a list of column names, or null if no partition key has been defined on the type.

This is the type-system counterpart to Table.PartitionKey. While Table.PartitionKey retrieves partition key metadata from a table value, Type.TablePartitionKey retrieves it from a table type definition.

### Use cases

  • Inspecting table type metadata in custom connector development.
  • Verifying that a table type has the expected partition key before using it.
  • Working with the Power Query SDK to read partitioned data source type definitions.

Partition keys indicate how a table's data is logically segmented. They are primarily relevant when working with partitioned data sources or building custom connectors that expose partitioned data to the Power Query engine for parallel evaluation.

Examples

Example 1: Check the partition key of a table type

let
    MyType = Type.ReplaceTablePartitionKey(
        type table [Region = text, Sales = number],
        {"Region"}
    ),
    Key = Type.TablePartitionKey(MyType)
in
    if Key = null then "No partition key" else Text.Combine(Key, ", ")

Compatibility

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