Cube.ApplyParameter

Table

Returns a cube after applying a parameter with arguments to it.

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

Syntax

Cube.ApplyParameter(cube as table, parameter as any, optional arguments as nullable list) as table

Parameters

NameTypeRequiredDescription
cubetableYesThe cube table to apply the parameter to.
parameteranyYesThe parameter to apply. Typically a value from Cube.Parameters.
argumentslistNoAn optional list of arguments to pass with the parameter.

Return Value

tableThe 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
    Filtered

Example 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

Compatibility

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