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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors