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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.