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
Anonymous
Not applicable

Help With RANKX

Hello Everyone, I am fairly new to PBI and I am having trouble with the rank x function.

 

I have four columns: SKU, Vendor, Total Instock, Total Count (See below for table). 

 

SKU

 

Vendor

Total Instock

Total Count

123456

 

10

100

125

456789

 

10

155

1478

147852

 

10

418

1025

258963

 

5

748

2588

369852

 

25

369

1478

123789

 

25

348

500

456357

 

31

256

900

159753

 

31

248

300

 

So far, I created the measure:

Measure Instock % = CALCULATE(DIVIDE(sum('In Stock'[Total Instock]),sum('In Stock'[Total Count])))
 
This measure is used to calculate a % instock.
 
I was then able to create a rank measure to figure out the rankings of instock % by SKU:
 
Measure rank sku = RANKX(ALL('In Stock'[pskudesc]),[Measure Instock %],,DESC)
 
What i am trying to accomplish is ranking by the vendors? But when I do make the measure below it results in 1s or some other scrambled numbers that do not make sense.
 
Measure rank vendor = RANKX(ALL('In Stock'[goldvendor]),[Measure Instock %],,DESC)
 
Thank you for your help and your time!
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Try ALLEXCEPT() function.

rank sku = RANKX(ALLEXCEPT('In Stock','In Stock'[Vendor]),'In Stock'[Instock %],,DESC)

2.PNG 

Best Regards,

Jay

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous ,

 

Try ALLEXCEPT() function.

rank sku = RANKX(ALLEXCEPT('In Stock','In Stock'[Vendor]),'In Stock'[Instock %],,DESC)

2.PNG 

Best Regards,

Jay

harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Try

 

Measure rank vendor = RANKX(ALL('Table'[Vendor],'Table'[SKU]),[Measure Instock %],,DESC)

 

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-2-of-3-calculated-measures

 

 

 

Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

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

Anonymous
Not applicable

Harsh,

 

I tried this, but it returned random numbers that did not rank the vendors.

 

-gps0014

Hi @Anonymous ,

 

Returning correct for me based on the data you shared.

 

 

 

1.jpg

 

 

 

Hi @Anonymous ,

 

Can you share the screenshot of your visualization ?

 

Regards,

HN

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.