Forum Discussion
Rankx all return 1
- Anonymous10 years ago
Anonymous CALCULATE() converts a row context to a filter context. Without it the row context at each step in the iteration doesn't work properly with the filter context coming from the ALLSELECTED(). You get an implicit CALCULATE when you reference an existing measure like this:
Total Sales = SUM(sales[sales amount])
Sales Rank = RANKX (ALLSELECTED(sales[employee number]), [Total Sales])
...but when you spell out the expression instead of using a measure you also have to spell out the invisible CALCULATE yourself. The above formula is identical to your
Sales Rank = RANKX( ALLSELECTED(sales[employee number]), CALCULATE( SUM(sales[sales amount]))
This article might help to explain it.
Anonymous CALCULATE() converts a row context to a filter context. Without it the row context at each step in the iteration doesn't work properly with the filter context coming from the ALLSELECTED(). You get an implicit CALCULATE when you reference an existing measure like this:
Total Sales = SUM(sales[sales amount])
Sales Rank = RANKX (ALLSELECTED(sales[employee number]), [Total Sales])
...but when you spell out the expression instead of using a measure you also have to spell out the invisible CALCULATE yourself. The above formula is identical to your
Sales Rank = RANKX( ALLSELECTED(sales[employee number]), CALCULATE( SUM(sales[sales amount]))
This article might help to explain it.
Anonymous Absolutely spot on! The link is also very useful. An eye opening lesson for Dax. Thanks.