Cube.ApplyParameter
TableReturns a cube after applying a parameter with arguments to it.
Syntax
Cube.ApplyParameter(cube as table, parameter as any, optional arguments as nullable list) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
cube | table | Yes | The cube table to apply the parameter to. |
parameter | any | Yes | The parameter to apply. Typically a value from Cube.Parameters. |
arguments | list | No | An optional list of arguments to pass with the parameter. |
Return Value
table — The cube table with the specified parameter and its arguments applied.
Remarks
Cube.ApplyParameter applies a parameter with optional arguments to a cube, returning the modified cube. Parameters are server-side objects defined within an Analysis Services model that allow dynamic filtering or configuration of cube behavior. They are similar to stored procedure parameters in relational databases.
The parameter is typically obtained from the table returned by Cube.Parameters. Each parameter in that table is represented as a function, and Cube.ApplyParameter provides an alternative way to invoke it with explicit arguments.
This function is useful when you need to programmatically apply parameters based on user input or dynamic conditions rather than hard-coding parameter values.
Examples
Example 1: Apply a parameter to a cube
let
Source = AnalysisServices.Database("localhost", "AdventureWorks"),
Cube = Source{[Name = "Adventure Works"]}[Data],
Params = Cube.Parameters(Cube),
CurrencyParam = Params{[Name = "Currency"]}[Value],
Filtered = Cube.ApplyParameter(Cube, CurrencyParam, {"USD"})
in
FilteredExample 2: Chain parameter application with dimension expansion
let
Source = AnalysisServices.Database("localhost", "AdventureWorks"),
Cube = Source{[Name = "Adventure Works"]}[Data],
Params = Cube.Parameters(Cube),
YearParam = Params{[Name = "Year"]}[Value],
FilteredCube = Cube.ApplyParameter(Cube, YearParam, {"2024"}),
WithProduct = Cube.AddAndExpandDimensionColumn(
FilteredCube,
{"[Product]"},
{"[Product].[Product Name]"}
)
in
WithProduct