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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
bir1concepts
Frequent Visitor

How can I use Sort by Column and RANKX at same time.

Hi all,

 

I used RANKX to set up my Power BI report before. But today I got some problems when using RANKX and Sort by Column function at the same time. I really need you help, I really appreciate that.

 

This is my test data, Product is sort by Product as normal

 

These are 2 measures to test data:

 

 

test_c = CONCATENATEX(ALL(test[Product]),CALCULATE(SUM(test[Qty])),,",",ASC) 

 

 

 

 

test_r = RANKX(ALL(test[Product]),CALCULATE(SUM(test[Qty])),,ASC) 

 

 

The result looks well. But I want to sort Product by column "Sort" 

 

After that when I come back to my 2 measures, it's give wrong number. I dont know why?

I did research a lot around to this problem, but I still did not get the answer. Did anyone get into this situation before, how can I solve this problem?

 

Thank you all

 

bir1concepts_1-1622098441762.png

bir1concepts_3-1622098625040.png

bir1concepts_0-1622098221671.png

bir1concepts_2-1622098493311.png

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@bir1concepts , Try Rank like

test_r = RANKX(ALL(test[Product], test[Sort),CALCULATE(SUM(test[Qty])),,ASC)

 

Same way you can try for another measures

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

2 REPLIES 2
bir1concepts
Frequent Visitor

Thank @amitchandak a lot, you saved my day ❤️

amitchandak
Super User
Super User

@bir1concepts , Try Rank like

test_r = RANKX(ALL(test[Product], test[Sort),CALCULATE(SUM(test[Qty])),,ASC)

 

Same way you can try for another measures

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

Helpful resources

Announcements
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.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.