Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Dynamic Rank Measure

I'm trying to create a measure that re-calculates the rank in the power pivot table everytime the user deselects a value or changes the group by row labels. For example, per table below, there are 3 ...
  • jdbuchanan71's avatar
    jdbuchanan71
    6 years ago

    Anonymous 

    Thank you for sharing the extended data set.  I didn't really like the -1 either and with the extended data set it doesn't work because there are many companies not represented on a given quote and each of them was returning BLANK which is treated as a 0 in the ranking.  This is fine if you do DESC but because we needed ASC it was counting them so the first company in Quote 1 that got a ranking was getting like 24.

    What we needed it to filter the list of companies that are getting ranked to just those with Rate so here we go.

    Ranking = 
    IF (
        ISFILTERED ( Quotes[Quote] ),
        RANKX ( FILTER ( ALL ( Quotes[Company] ), [Rate Total] ), [Rate Total],, ASC ),
        AVERAGEX (
            VALUES ( Quotes[Quote] ),
            RANKX ( FILTER ( ALL ( Quotes[Company] ), [Rate Total] ), [Rate Total],, ASC )
        )
    )

    This portion of the measure (FILTER ( ALL ( Quotes[Company] ), [Rate Total]) returns all companies that have a rate in the quote context and if the Quote is not visable we still have quote context because we are iterating over the list of quotes then averaging the Ranking.

  • Anonymous's avatar
    Anonymous
    6 years ago

    jdbuchanan71 Thanks a lot. Worked like a charm once I replaced All with AllSelected to make sure that the user selects on CompanyName was also taken into consideration by the measure.