Here are some steps that I recite when I am stuck with a complex problem, it is always good remember CALCULATE’s execution order.
-
Evaluates all the filter arguments of CALCULATE in the original filter context that is active outside CALCULATE and then are kept aside
-
CALCULATE creates a new Filter by copying the original filter context
-
If it is called in a Row Context, either by an iterator or Calculated column then it takes that particular row and create an equivalent filter from values of each column in that row and then add it to the new filter context created in the second step. Otherwise this step will be skipped
-
Modifiers such as ALL, ALLSELECTED, ALLEXCEPT, ALLNOBLANKROW, CROSSFILTER, USERELATIONSHIP, KEEPFILTERS etc. are evaluated so that they can alter the effect of context transition if required
-
The filter arguments that were evaluated in step 1 are applied to the new filter context
-
It executes the first argument in the newly created filter context