Cube.PropertyKey

Table

Returns the key of a property.

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

Syntax

Cube.PropertyKey(property as any) as any

Parameters

NameTypeRequiredDescription
propertyanyYesA property value from which to extract the key.

Return Value

anyThe key identifier of the specified property.

Remarks

Cube.PropertyKey returns the key of the specified property. Properties in an Analysis Services cube have both a display name and an internal key identifier. The key is used to uniquely identify a property, especially in cases where multiple properties might share similar display names across different dimensions or hierarchies.

This function is typically used with property values obtained from Cube.Properties or Cube.MeasureProperties. The returned key can be used to programmatically reference properties in further cube operations.

Examples

Example 1: Get the key of a dimension property

let
    Source = AnalysisServices.Database("localhost", "AdventureWorks"),
    Cube = Source{[Name = "Adventure Works"]}[Data],
    WithProduct = Cube.AddAndExpandDimensionColumn(
        Cube,
        {"[Product]"},
        {"[Product].[Product Name]"}
    ),
    Props = Cube.Properties(WithProduct),
    FirstProp = Props{0}[Value],
    Key = Cube.PropertyKey(FirstProp)
in
    Key

Example 2: List property names with their keys

let
    Source = AnalysisServices.Database("localhost", "AdventureWorks"),
    Cube = Source{[Name = "Adventure Works"]}[Data],
    WithProduct = Cube.AddAndExpandDimensionColumn(
        Cube,
        {"[Product]"},
        {"[Product].[Product Name]"}
    ),
    Props = Cube.Properties(WithProduct),
    WithKeys = Table.AddColumn(
        Props,
        "Key",
        each Cube.PropertyKey([Value])
    )
in
    WithKeys

Compatibility

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