CALCULATE Function
Description:
The CALCULATE function evaluates an expression in a context that is modified by the specified filters.
Return Value:
CALCULATE returns a single value, that is the result of the expression.
Syntax:
CALCULATE( <expression> , <filter1> , <filter2>…)
- Description of the parameters:
PARAMETER |
DESCRIPTION |
---|---|
expression |
The expression to be evaluated |
filter |
list of Boolean expression or a table expression that defines a filter |
Example:
The following example creates a measure that calculates the Sales Amount during working days.
For the expression argument, we will calculate the sum of sales using the SUM function, then we will add to the CALCULATE function two filter arguments to modify the result of the sum keeping only the working days.
WorkinDays_SalesAmount =
CALCULATE(
SUM(Sales[SalesAmount]),
'Calendar'[DayOfWeekName] <> "Saturday",
'Calendar'[DayOfWeekName] <> "Sunday"
)
The CALCULATE function changes the context in which the data is filtered.
If there is a filter applied to a column used in a filter argument, it will be removed and replaced by the the filter argument
Related Video: