Cube.AddMeasureColumn
TableAdds a column to the cube containing the results of a measure applied in each row's context.
Syntax
Cube.AddMeasureColumn(cube as table, column as text, measureSelector as any) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
cube | table | Yes | The cube table to add the measure column to. |
column | text | Yes | The name of the new column to add. |
measureSelector | any | Yes | The measure to apply. Typically a value from Cube.Measures. |
Return Value
table — The cube table with a new column containing measure values evaluated in the row context of each row.
Remarks
Cube.AddMeasureColumn adds a column with the specified name to a cube table. The column contains the results of the measure applied in the row context of each row. Measure application is affected by changes to dimensional granularity and slicing -- measure values are automatically adjusted after cube operations such as expanding or collapsing dimensions.
The measure selector is typically obtained from the table returned by Cube.Measures. Each measure is represented as a function that evaluates based on the current dimensional context of the row.
This function is the measure counterpart of Cube.AddAndExpandDimensionColumn. While the dimension function adds attribute columns that define the granularity, Cube.AddMeasureColumn adds the numeric (or other typed) values that are aggregated at that granularity.
Examples
Example 1: Add an Internet Sales Amount measure
let
Source = AnalysisServices.Database("localhost", "AdventureWorks"),
Cube = Source{[Name = "Adventure Works"]}[Data],
WithMeasure = Cube.AddMeasureColumn(
Cube,
"Internet Sales",
{"[Measures].[Internet Sales Amount]"}
)
in
WithMeasureExample 2: Add multiple measures to a cube
let
Source = AnalysisServices.Database("localhost", "AdventureWorks"),
Cube = Source{[Name = "Adventure Works"]}[Data],
WithProduct = Cube.AddAndExpandDimensionColumn(
Cube,
{"[Product]"},
{"[Product].[Product Name]"}
),
WithSales = Cube.AddMeasureColumn(
WithProduct,
"Sales Amount",
{"[Measures].[Internet Sales Amount]"}
),
WithCount = Cube.AddMeasureColumn(
WithSales,
"Order Count",
{"[Measures].[Internet Order Count]"}
)
in
WithCount