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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

RANK - How can i do this??

Hwlloe, i would like to know how to apply rank in this example, i have created a kpi and category measure. I want to know how to do the top 3 highest of category 1 and the lowest top 3 of category 2.

 

I have this

citykpicategory

city 1

1001
city 2

200

2
city 33001
city 44001
city 55002
city 66002
city 77002
city 88001

i want this

 

citykpicategoryrank
city 880011
city 440012
city 330013
city 660021
city 550022
city 220023

Thanks!

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Based on your description, KPI and category are measures.

Try to create a measure like this and apply it to visual level filter. 

Measure =
IF (
    [category Measure] = 1,
    RANKX (
        FILTER ( ALLSELECTED ( 'Table'[city] ), [category Measure] = 1 ),
        [Kpi Measure],
        ,
        ASC,
        DENSE
    ),
    IF (
        [category Measure] = 2,
        RANKX (
            FILTER ( ALLSELECTED ( 'Table'[city] ), [category Measure] = 2 ),
            [Kpi Measure],
            ,
            DESC,
            DENSE
        )
    )
)

Sample .PBIX 

 

Best Regards,
Liang
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

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Please find the attached file after the signature.  Rank and filter on Rank have been used.

 

 

 

Measure = RANKX(ALL('Table (2)'[city]),CALCULATE(sum('Table (2)'[kpi])))

You can also try top N
Top 10 City Rank = CALCULATE(CALCULATE(sum('Table (2)'[kpi])),TOPN(10,all('Table (2)'[City]),CALCULATE(sum('Table (2)'[kpi])),DESC),VALUES('Table (2)'[City]))
	

 

Sumanth_23
Memorable Member
Memorable Member

hi @Anonymous - you should be able to achieve this ranking by following the steps in the below post

https://community.powerbi.com/t5/Desktop/Sequence-number/m-p/1367645#M585159

 

Please mark the post as a solution and provide a 👍 if my comment helped with solving your issue. Thanks!

Regards,
Sumanth

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!

Proud to be a Super User!



Hi @Anonymous ,

 

Based on your description, KPI and category are measures.

Try to create a measure like this and apply it to visual level filter. 

Measure =
IF (
    [category Measure] = 1,
    RANKX (
        FILTER ( ALLSELECTED ( 'Table'[city] ), [category Measure] = 1 ),
        [Kpi Measure],
        ,
        ASC,
        DENSE
    ),
    IF (
        [category Measure] = 2,
        RANKX (
            FILTER ( ALLSELECTED ( 'Table'[city] ), [category Measure] = 2 ),
            [Kpi Measure],
            ,
            DESC,
            DENSE
        )
    )
)

Sample .PBIX 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you so much! it really works

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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