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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
BhavaniK
Frequent Visitor

Need help on Ranking within table.

Hi Team,

 

I'm looking for some help to achieve the logic. Right now I have table with these columns Event, Number, Location, sum of delay imapact. in the visual filter I have added, Number-> Top 5-> sum of delay.  here is the actual problem arise, if there is multiple rows have same delay then in the table it shows more than Top 5. is anyone can help to resolve this issue within power bi? Sample data:

EventNomberLocationDelay
 1Hyd11
 2chennai3
 3madurai2
 4nagarcoil2
 5salem2
 6rmd2
 7trichy1
 8ngt1
1 ACCEPTED SOLUTION
KNP
Super User
Super User

It really depends on what you're expecting as an output.

 

Assumptions for the below:

- I used your sample data and created a table called 'sample'

- I created a measure called _delay = SUM('sample'[Delay])

 

Create this measure, put it in the visual filters where it is 1.

 

__rank = 
VAR __locations =
    ALLSELECTED('sample')
VAR __ranked =
    ADDCOLUMNS(
        __locations
        , "__delay", [_delay]
        , "__rank", RANKX(
            __locations
            , [_delay]
            , BLANK()
            , DESC
            , Skip
        )
    )
VAR __top =
    TOPN(
        5
        , __ranked
        , [__rank], ASC
        , [__delay], DESC
        , 'sample'[Location], ASC
    )
VAR __isTop =
    CONTAINS(
        __top
        , 'sample'[Location], SELECTEDVALUE('sample'[Location])
    )
VAR __result =
    IF(
        __isTop
        , 1
        , 0
    )
RETURN __result

 

KNP_0-1760491585126.png

 

My code is GitHub Copilot assisted, but always tested.

 

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Clearly show the result that you are expecting.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @BhavaniK ,

Thanks for reaching out to the Microsoft fabric community forum. 

 

I would also take a moment to thank @KNP   , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

I hope the below details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you 

 

Best Regards, 
Community Support Team  

Hi @BhavaniK ,

I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you.
 

Regards,
Microsoft Fabric Community Support Team.

Shahid12523
Community Champion
Community Champion

Rank by Delay =
RANKX(
ALL('YourTable'[Number]),
CALCULATE(SUM('YourTable'[Delay])),
, DESC, DENSE
)

Shahed Shaikh
KNP
Super User
Super User

It really depends on what you're expecting as an output.

 

Assumptions for the below:

- I used your sample data and created a table called 'sample'

- I created a measure called _delay = SUM('sample'[Delay])

 

Create this measure, put it in the visual filters where it is 1.

 

__rank = 
VAR __locations =
    ALLSELECTED('sample')
VAR __ranked =
    ADDCOLUMNS(
        __locations
        , "__delay", [_delay]
        , "__rank", RANKX(
            __locations
            , [_delay]
            , BLANK()
            , DESC
            , Skip
        )
    )
VAR __top =
    TOPN(
        5
        , __ranked
        , [__rank], ASC
        , [__delay], DESC
        , 'sample'[Location], ASC
    )
VAR __isTop =
    CONTAINS(
        __top
        , 'sample'[Location], SELECTEDVALUE('sample'[Location])
    )
VAR __result =
    IF(
        __isTop
        , 1
        , 0
    )
RETURN __result

 

KNP_0-1760491585126.png

 

My code is GitHub Copilot assisted, but always tested.

 

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.