Understanding evaluation contexts
In the previous section, we used the SUMX
function to sum the result of multiplying price by quantity. Similarly, we achieved the same result by creating a calculated column without the need to use the SUMX
function.
Measures
The following code refers to a measure:
SUMX TEST = SUMX ( Products, Products[Price] * Products[Qty] )
Calculated column
The following code refers to a calculated column:
Total = Products[Price] * Products[Qty]
The fact that both calculations return the same result is related to the execution environment, specifically the evaluation context in which they are executed.
A simple example to understand this concept is by adding the measure to a card in your report. As you can see, the result is the total sum of each multiplication of price by quantity. This is essentially the total sales as we have renamed the measure: