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

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

Reply
kimalto452
Frequent Visitor

RANKX duplicated values, showing only 1 or showing duplicate ranking

hi, I'm new with power bi . How I can do ranking for sum price of orders.

I have table "orders" which have column "product" and "price" , the product column have duplicated values with diferent price, I need sum all price by product and then rank them.

ProductTotal ChargeRank
ProdAAA1501
ProdBBB1002
ProdCCC803

 

Rank = RANKX(ALL(orders), SUMX(orders,orders[price])) 
with this measure I recive all 1
 
with this code I recive duplicated rank for diferent price
Rank = RANKX( ALL(orders), CALCULATE(SUMX(orders,orders[price])))
for example
ProdAA1501
ProdBB1301
ProdCC1203
  

 

Thanks!!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@kimalto452 ,

if it's a column range

Rank á RANKX(ALL(orders), orders[price],,desc,dense)

if it's a range of measurement
Treat
Total charge : SUM(orders[price]) // or similar formula

Then

Range Measurement -Range - RANKX(ALL(orders[Product]), [Total Charge],,desc,dense)
Or
Range Measurement -Range - RANKX(ALL(orders[Product]), [Total Charge],,desc,dense) + rand()/1000

For range See these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

What result do you get with these measures?

Total price = SUM(Orders[Price])

Rank = rankx(all(Orders[product]),[Total price])


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

@kimalto452 ,

if it's a column range

Rank á RANKX(ALL(orders), orders[price],,desc,dense)

if it's a range of measurement
Treat
Total charge : SUM(orders[price]) // or similar formula

Then

Range Measurement -Range - RANKX(ALL(orders[Product]), [Total Charge],,desc,dense)
Or
Range Measurement -Range - RANKX(ALL(orders[Product]), [Total Charge],,desc,dense) + rand()/1000

For range See these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Total Charge = SUM(orders[price]) 

then

Rank Measure = RANKX(ALL(orders[Product]), [Total Charge],,desc,dense)

 

its works !! thanks !  

can you explain please why I need use orders[Product] in ALL function ? because whe I put only table name ALL(orders) its dosen't works...

Hi,

You are welcome.  You must use ALL(Orders[Product]) because you have dragged Product to your visual.

If my previous reply helped, please mark it as Answer.


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

@kimalto452 - You can use RAND() to break ties:

Rank = RANKX( ALL(orders),SUMX(orders,orders[price])*(RAND()/100))

 

Also, you don't need CALCULATE there.

 

This might also help - https://community.powerbi.com/t5/Quick-Measures-Gallery/To-Bleep-with-RANKX/m-p/1042520#M452

 

Finally there is also this: https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Mythical-DAX-Index/m-p/1093214#M528

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

9dea4195701980116fedecc4f280cbe4

this dosen't work

Rank = RANKX( ALL(orders),SUMX(orders,orders[price])*(RAND()/100))

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.