Cube.Transform

Table

Applies a list of cube functions as transforms to a cube.

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

Syntax

Cube.Transform(cube as table, transforms as list) as table

Parameters

NameTypeRequiredDescription
cubetableYesThe cube table to apply transforms to.
transformslistYesA list of cube functions to apply to the cube in sequence.

Return Value

tableThe cube table with all specified transforms applied in sequence.

Remarks

Cube.Transform applies a list of cube functions (transforms) to the specified cube in sequence. Each transform in the list is a function that takes a cube and returns a modified cube. This provides a compact way to compose multiple cube operations into a single step rather than chaining them individually.

The transforms list typically contains partially applied Cube functions such as Cube.AddAndExpandDimensionColumn, Cube.AddMeasureColumn, Cube.CollapseAndRemoveColumns, or Cube.ApplyParameter. Each function in the list receives the result of the previous transform.

This function is useful for building reusable cube transformation pipelines or for programmatically constructing a series of cube operations.

Examples

Example 1: Apply multiple transforms to a cube

let
    Source = AnalysisServices.Database("localhost", "AdventureWorks"),
    Cube = Source{[Name = "Adventure Works"]}[Data],
    Transformed = Cube.Transform(Cube, {
        each Cube.AddAndExpandDimensionColumn(
            _,
            {"[Product]"},
            {"[Product].[Product Name]"}
        ),
        each Cube.AddMeasureColumn(
            _,
            "Sales",
            {"[Measures].[Internet Sales Amount]"}
        )
    })
in
    Transformed

Example 2: Build a dynamic transform pipeline

let
    Source = AnalysisServices.Database("localhost", "AdventureWorks"),
    Cube = Source{[Name = "Adventure Works"]}[Data],
    Transforms = {
        each Cube.AddAndExpandDimensionColumn(
            _,
            {"[Date]"},
            {"[Date].[Calendar Year]"},
            {"Year"}
        ),
        each Cube.AddAndExpandDimensionColumn(
            _,
            {"[Product]"},
            {"[Product].[Category]"},
            {"Category"}
        ),
        each Cube.AddMeasureColumn(
            _,
            "Total Sales",
            {"[Measures].[Internet Sales Amount]"}
        ),
        each Cube.AddMeasureColumn(
            _,
            "Order Count",
            {"[Measures].[Internet Order Count]"}
        )
    },
    Result = Cube.Transform(Cube, Transforms)
in
    Result

Compatibility

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