Forum Discussion

paulpassot78's avatar
paulpassot78
New Member
3 years ago
Solved

Using a measure within a measure

Hi,   I have a simple table with two columns : City Name, and Value I'm trying to create a measure that ranks cites by values.   I created a measure = RANKX(ALL(Cities), SUM(Values)).  It retur...
  • FreemanZ's avatar
    3 years ago

    hi paulpassot78 

    Because your second expression reference a measure and measures have a hidden CALCULATE arround. If you wrap a CALCULATE in your first expression, it shall also work.


    Why CALCULATE is needed here?
    Context transition. RANKX is an iterator, the first argument provides a row context for the second argument. A CALCULATE is needed for context transition (converting a row context to filter context), so we get different value for different city.


    RANKX might be more complicated as it seems. Check this for further info:
    https://www.sqlbi.com/articles/use-of-rankx-in-power-bi-measures/