Cube.ReplaceDimensions
TableReplaces the set of dimensions returned by Cube.Dimensions for a cube.
Syntax
Cube.ReplaceDimensions(cube as table, dimensions as any) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
cube | table | Yes | The cube table whose dimensions are to be replaced. |
dimensions | any | Yes | The replacement dimensions to use. Typically a modified version of the table returned by Cube.Dimensions. |
Return Value
table — The cube table with the modified set of dimensions.
Remarks
Cube.ReplaceDimensions replaces the set of dimensions returned by Cube.Dimensions for the given cube. This allows you to customize or augment the dimension definitions before expanding them. For example, you can add an ID column to a dimension attribute so that the data source groups on the internal ID rather than the displayed value.
This function is an advanced operation that modifies the cube's metadata layer. The dimensions parameter is typically a modified version of the table originally returned by Cube.Dimensions. After replacement, subsequent calls to Cube.Dimensions on the resulting cube will return the new dimensions.
Common use cases include:
- Adding key columns to dimensions for more efficient grouping.
- Filtering or reordering the set of available dimensions.
- Augmenting dimension attribute definitions with additional hierarchies or properties.
Examples
Example 1: Replace dimensions with a modified set
let
Source = AnalysisServices.Database("localhost", "AdventureWorks"),
Cube = Source{[Name = "Adventure Works"]}[Data],
Dims = Cube.Dimensions(Cube),
// Modify the dimensions table as needed
ModifiedDims = Table.SelectRows(Dims, each [Name] <> "Internal"),
NewCube = Cube.ReplaceDimensions(Cube, ModifiedDims)
in
NewCubeExample 2: Replace dimensions to customize grouping behavior
let
Source = AnalysisServices.Database("localhost", "AdventureWorks"),
Cube = Source{[Name = "Adventure Works"]}[Data],
OriginalDims = Cube.Dimensions(Cube),
CustomDims = OriginalDims,
CubeWithCustomDims = Cube.ReplaceDimensions(Cube, CustomDims),
WithProduct = Cube.AddAndExpandDimensionColumn(
CubeWithCustomDims,
{"[Product]"},
{"[Product].[Product Name]"}
)
in
WithProduct