Forum Discussion

vijayan_ja's avatar
vijayan_ja
Frequent Visitor
7 years ago
Solved

DAX measure for top 10 rank using Rankx function

Dear all,

 

i am looking for the output of top 10 values based on the category(Subject), The problem is i am working on the real time dataset, which dosen't allow to use any calculated column.

 

the output has duplicate ranks, which leads to bring more than 10 values due to ties in the value.

 

The formula used 

Rank = IF([FlagLatest]=1,RANKX(FILTER(ALLSELECTED(RealTimeTest),[FlagLatest]=1 && RealTimeTest[metric_name]=MAX(RealTimeTest[metric_name])),[SumwithContext],,DESC,Skip))
 
Please help.
  • Hi vijayan_ja ,

     

    Please try this:

    Rank =
    IF (
        [FlagLatest] = 1,
        RANKX (
            FILTER (
                ALLSELECTED ( RealTimeTest ),
                [FlagLatest] = 1
                    && RealTimeTest[metric_name] = MAX ( RealTimeTest[metric_name] )
            ),
            [SumwithContext],
            ,
            DESC,
            DENSE
        )
    )

    Best regards,

    Yuliana Gu

8 Replies

  • vijayan_ja in this article there is a section which talks about breaking ties, scroll down the page on article and you need similar approach to make it work in your model.

    • vijayan_ja's avatar
      vijayan_ja
      Frequent Visitor

      Breaking ties using date column dosen't works, because the date value is same acrros the table. and we used Rand() but no luck.

      • parry2k's avatar
        parry2k
        Icon for Super User rankSuper User

        vijayan_ja you have to break the ties somehow, why not add index column which will be unique for each record and then break ties based on that, it should be easy, no?

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi vijayan_ja ,

     

    Please try this:

    Rank =
    IF (
        [FlagLatest] = 1,
        RANKX (
            FILTER (
                ALLSELECTED ( RealTimeTest ),
                [FlagLatest] = 1
                    && RealTimeTest[metric_name] = MAX ( RealTimeTest[metric_name] )
            ),
            [SumwithContext],
            ,
            DESC,
            DENSE
        )
    )

    Best regards,

    Yuliana Gu