
Extreme DAX
By :

Changing context using DAX code is one of the most powerful features of DAX. The DAX CALCULATE
function, which is used for context transformation, is arguably the most important DAX function. By specifying filter expressions in CALCULATE
, you can control the subsets of rows your formula works on. This can be done by adding or replacing filters, but also by removing filters from the context. As relationships play an important role in context by propagating filters, activating or inactivating relationships or changing their filter propagation behavior is a form of context transformation as well.
Let's start with a sample DAX measure:
SalesLargeUnitAmount =
CALCULATE(
SUM(fSales[SalesAmount]),
fSales[UnitAmount] > 25
)
This measure returns the sales on transactions in which more than 25 units were sold. The first argument of CALCULATE
is the calculation to be performed, in this case, the sum of the SalesAmount
column in fSales...