Cube.AddAndExpandDimensionColumn
TableMerges a dimension into the cube's filter context and expands specified dimension attributes as new columns.
Syntax
Cube.AddAndExpandDimensionColumn(cube as table, dimensionSelector as any, attributeNames as list, optional newColumnNames as any) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
cube | table | Yes | The cube table to add the dimension column to. |
dimensionSelector | any | Yes | The dimension to merge into the cube's filter context. Typically a value from Cube.Dimensions. |
attributeNames | list | Yes | A list of dimension attribute names to expand as columns in the tabular view. |
newColumnNames | any | No | Optional list of new column names to use instead of the attribute names. |
Return Value
table — The cube table with the specified dimension attributes added as new columns and the filter context updated to the expanded granularity.
Remarks
Cube.AddAndExpandDimensionColumn merges a specified dimension table into the filter context of a cube and changes the dimensional granularity by expanding the specified set of dimension attributes. The dimension attributes are added to the tabular view as new columns. If newColumnNames is provided, those names are used for the new columns; otherwise the attribute names from attributeNames are used.
This function is the primary way to add dimension columns to a cube table returned by AnalysisServices.Database. Each call increases the granularity of the cube results by adding a new level of detail. The dimension selector is typically obtained from the table returned by Cube.Dimensions.
This is the dimensional counterpart of Cube.CollapseAndRemoveColumns -- one expands dimensions and the other collapses them. Together they control which dimension attributes appear in the flattened tabular view of the cube.
Examples
Example 1: Expand a Product dimension into a cube
let
Source = AnalysisServices.Database("localhost", "AdventureWorks"),
Cube = Source{[Name = "Adventure Works"]}[Data],
WithProduct = Cube.AddAndExpandDimensionColumn(
Cube,
{"[Product]"},
{"[Product].[Product Name]"}
)
in
WithProductExample 2: Expand with custom column names
let
Source = AnalysisServices.Database("localhost", "AdventureWorks"),
Cube = Source{[Name = "Adventure Works"]}[Data],
WithDate = Cube.AddAndExpandDimensionColumn(
Cube,
{"[Date]"},
{"[Date].[Calendar Year]", "[Date].[Month]"},
{"Year", "Month"}
)
in
WithDate