The CALCULATETABLE function evaluates an expression that generates a table in a context modified by the filters passed as arguments.
CALCULATETABLE(
expression,
filter1,
filter2...
)
- expression: Expression to evaluate.
- filter1, filter2...: Optional arguments. List of Boolean expressions or table expressions that define filters to apply to expression.
The CALCULATETABLE function returns a table.
The expression used as the first argument must generate a table.
Filters that are Boolean expressions:
- They cannot refer to measurements.
- They cannot use nested CALCULATE functions.
- They cannot use functions that scan a table or that return a table, including aggregate functions.
In any case, these filters can use functions that retrieve simple values or that return a scalar.
In this example we want to add the amounts for those sales made in 2003, for which we create an intermediate table filtered according to this criterion using the CALCULATETABLE function. Once created, we go through it with the SUMX function adding the SalesAmount field:
Sales 2003 =
SUMX(
CALCULATETABLE(Sales, 'Calendar'[Year]=2003),
Sales[SalesAmount]
)