Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
vijayan_ja
Frequent Visitor

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.dataset.JPGRank.JPG
1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft 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

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
v-yulgu-msft
Microsoft Employee
Microsoft 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

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
parry2k
Super User
Super User

@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.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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

@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?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

TieBreak.JPG

The Rand() function dosen't given the expected output.

 

 

 

Maybe you can add a super insignificant amount to your sum? 
Like:

[SumwithContext] + (RAND()/1000)

Then you rank on this measure while still displaying [SumwithContext]?


Connect on LinkedIn

As i mentioned, addind index column is not possible, due to the real time dataset. 

interesting, well i guess you have to somehow find a unique record, seems like that is the requirement to solve your problem. I'm surprise that random didn't worked.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors