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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Sajid02
Helper I
Helper I

How to get ranking

Hi Folks,

Need help on the ranking formula . As per the need :- 

1. We need to show ranking as per Product and price from higher to lower i.e higher value should be 1 and then goes on ....

2. We need to show all city in the same row of a particular product. For example:- Pls find the snips 

 

Case 1-

Sajid02_0-1674648052590.png

Case 2 -

Sajid02_1-1674648061110.png

For ranking i am trying to write DAX as 

1.

Ranking = IF('Table'[Product] = "Healthcare", RANKX('Table','Table'[Sales], ,DESC, Dense) , RANKX('Table','Table'[Sales], ,DESC, Dense))
2.
Ranking 1 =
RANKX (
    ALLSELECTED ( 'Table'[Product], 'Table'[City]),
    CALCULATE ( SUM ( 'Table'[Sales] ) ),
    ,
    DESC,
    DENSE
)
 
 
Both these codes are showing wrong output as :-
Sajid02_2-1674648191608.png


Kinldy help me to solve this 

4 REPLIES 4
mh2587
Super User
Super User

rank = RANKX( FILTER( data, AND( data[Product] = EARLIER(data[Product]), data[City] = EARLIER(data[City]))), data[Price], , Dense)
--Try this one hope it works 

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



@MH 

Hi , 

This is not working as passing more than 2 argument in filter function is not accepting 

Snip 

Sajid02_0-1674727662726.png

 



Anonymous
Not applicable

For case 1 could you try this please?

Ranking = VAR healthcare_products = FILTER('Table', 'Table'[Product] = "Healthcare") RETURN RANKX(healthcare_products, healthcare_products[Sales], , DESC, Dense)

 

let me know if this gives desired result, if so I should be able to do case 2 🙂 

Hi @Anonymous 

 

I tried this with a minor changes in the DAX but still showing the wrong ranking for Pharmacy in Pune . PLs find below snip 

Sajid02_0-1674719636672.png

 



Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors