DAX Filter - CALCULATE function



Description

Evaluates an expression in a context that is modified by the specified filters.

Syntax

CALCULATE (<expression>, [<filter1>], [<filter2>] …) 

Parameters

Sr.No. Parameter & Description
1

expression

The expression to be evaluated.

2

filter1, filter2, …

Optional.

A comma separated list of Boolean expressions or a table expression that defines a filter.

Return Value

The value that is the result of the expression.

Remarks

The expression used as the first parameter is essentially the same as a calculated field.

If Boolean expressions are used as arguments, the following restrictions apply −

  • An expression cannot reference a calculated field.

  • An expression cannot use a nested CALCULATE function.

  • An expression cannot use any function that scans a table or returns a table, including aggregation functions.

However, a Boolean expression can use any function that looks up a single value, or that calculates a scalar value.

If the data has been filtered, the CALCULATE function changes the context in which the data is filtered, and evaluates the expression in the new context that you specify. For each column used in a filter argument, any existing filters on that column are removed, and the filter used in the filter argument is applied instead.

Example

= COUNTA (Results[Medal])/CALCULATE (COUNTA (Results[Medal], ALL (Results)) 
dax_functions_filter.htm
Advertisements