CONTEXT TRANSITION using CALCULATE

A fundamental difference between the two contexts in DAX is that a row context does not propagate through or follow relationship automatically whereas a filter context does.

One of the sweet things that CALCULATE function does in DAX is to transform Row Context of a calculated column into equivalent Filter Context.

A simple illustration will make it easy to understand.

Click here to Download the illustrative example.  In this example we have data model of two tables. The DATA TABLE contains the Earnings of Top 10 Highest paid athletes for each year from 2009 to 2013. Many players as you can see have appeared multiple times in this list . For example Tiger Woods has been there in each of the 5 years. The second table “ATHLETES TABLE” or “LOOKUP TABLE” contains information regarding Sport and Country of the Athlete. The two tables and the relationship between them is depicted below

 

Lets add a calculated column to “ATHLETES TABLE” or “LOOK UP TABLE” to get the total earnings for each athlete from the “DATA TABLE”. The formula for the Calculated Column is “=sum(Data[Earnings)” i.e. sum of Column “Earnings”in”Data” Table

 

The result of “Sum (Data[Earnings]) is the sum of entire Earnings Column in the DataTable. Why? Becasue there is no Filter Context inside a calculated column that would propagate through the relationship and get the sum relevant to each row. The row context in the ATHLETES table does not propagate through relationship automatically.

Now lets insert another calculated column and wrap the same formula inside CALCULATE   i.e. =CALCULATE(sum(Data[earnings])

we get the following results.

 

This is what is known as “CONTEXT TRANSITION”.