Forum Discussion

daanodinot's avatar
daanodinot
Frequent Visitor
3 years ago
Solved

Row and Filter contexts

I'm still massively confused by row and filter contexts. Here's a solution (a measure) to an exercise I was doing.   Ranking = RANKX(     ALL(Series),     CALCULATE(SUM(Series[Viewers (m)])),   ...
  • v-xiaosun-msft's avatar
    3 years ago

    Hi daanodinot ,

     

    According to your description, I created a sample. Measure 2 is using ALL function.

    When using RANKX function without ALL function, the following steps will be performed.

    RANKX(<table>, <expression>[, <value>[, <order>[, <ties>]]])

    Step1: Calculate the query context.

    Step2: The RANKX function creates an iteration context in Table Score.

    Step3: Compute expression, perform a context transformation, change to a filtering context again, and generate a data series of ranking.

    Step4: Calculate the value in the query context.

    Step5: Calculate the rank of value in the data series in the query context.

    Note that in Step 5, the query context, in addition to being used to calculate the value, but also for filtering the data series, so that all ranking results are 1.

    But when you use ALL function, it will only clear the filter of data columns when calculating the rank of value and does not affect the expression time and value calculation. Therefore, you can get the correct result.

     

    Best Regards,
    Community Support Team _ xiaosun

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.