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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Flynnk31
Regular Visitor

RANKX on measure

Hi All, 

I'm relatively new to PowerBI and moreso DAX.  I am having an issue trying to do a RANKX on a "Total_Cost" measure within one of my reports.  So what I have right now is a list of items per lot (can have many lots per item), and I need to group by the item (No_ field) for the Total Cost (Total_Cost measure).   So this is what I have for that measure: 

Total_Cost = SUMX(ALL(DaysToConsumption[No_]), CALCULATE(SUM(DaysToConsumption[TotalCost])))

 

 

What I want to do is now rank all of the ItemNumbers by that Total_Cost, and I can't get it to behave like I would expect it to.  I have tried a lot of different ways to write it, but I think this should be the correct way to find the Rank:

 

Rank = RANKX(ALL(DaysToConsumption[No_]), [Total_Cost], , DESC)

  However, when I do this, everything gets a rank of 1.  So then I tried this:

 

 

Rank = RANKX(ALL(DaysToConsumption), [Total_Cost], , DESC)

But that brings back even a more confusing Rank for each:

 

No_	Total_Cost	Rank	Total_Qty
109906	$1,401,983.21 	1	348939.648
101298	$1,039,526.08 	1	241073.01
107829	$916,293.34 	1	235119.623
109337	$484,197.69 	1	121738.012
110850	$484,197.69 	1	121738.012
F107610	$392,978.66 	1	86440
109318	$379,841.68 	1	4498.885
101348	$348,141.92 	1	77950
101852	$335,478.74 	1	875350
110952	$326,432.63 	1	125684.832
103841	$266,281.98 	1	616015.685
103848	$266,281.98 	1	616015.685
106148	$255,378.16 	1	77601.92
110139	$246,321.39 	1	48170.51
103780	$222,191.07 	1	63100
111281	$202,007.97 	1	40300.088
108809	$195,752.24 	1	198462.05
110872	$185,024.04 	2	13350
101263	$171,266.72 	3	37037.28
110693	$167,599.50 	4	56051.955
109761	$167,092.20 	4	1212.53
101553	$162,654.00 	5	126005.523
108747	$162,346.68 	5	31569.872
110301	$142,667.00 	14	19950
F107608	$139,596.86 	15	33680
108117	$138,499.44 	15	13221.788
110986	$127,576.03 	16	5850
106814	$112,364.99 	19	40564.64
109964	$111,521.14 	20	260000
108825	$110,496.44 	20	16950
107043	$106,046.08 	27	5297.8
106534	$100,274.78 	32	112000

 

Any ideas would be very helpful!  
Thanks

10 REPLIES 10

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.