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

Trouble with RankX

Objective: Have a column presenting the rank of customer based on total sales in descending order

 

Data Format:

Data Format.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

What has not worked:

Ranking =
RANKX(
ALLSELECTED(Table_1046),
CALCULATE(SUM(Table_1046[Extended Price]))
,,DESC
)
 
Also tried:
Rank v2 = IF(HASONEVALUE(Table_1046[Billing Customer Number]), RANKX(ALL(Table_1046[Billing Customer Number]), [Parts Sales]) )
 
Resulted in: 
RankX Help 1.JPG
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Definitely feeling like an idiot here as this doesn't seem like this should be as challenging as it has turned out to be

 

8 REPLIES 8
parry2k
Super User
Super User

@Anonymous there is detail blog post on RANK, here is link of 1 of 3. hope this helps.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thank you for the link.

 

Should I treat the Billing Customer Number as the subcategory then? Attempting based on that does seem to rank them, but not quite like I'd imagined.

 

DAX attempted:

 

Rankv4 = RANKX(FILTER(Table_1046, Table_1046[Billing Customer Number]=EARLIER(Table_1046[Billing Customer Number])), SUM(Table_1046[Extended Price]))
 
Result: 

RankX Help 2.JPG
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
It seems to be working to some extent, but I need to figure out why the numbers are jumping around like that. I tried adding the ASC or DESC to the DAX statement, but it did not change anything. Perhaps I'm putting it in the wrong place?
 
Rankv4 = RANKX(FILTER(Table_1046, Table_1046[Billing Customer Number]=EARLIER(Table_1046[Billing Customer Number])), SUM(Table_1046[Extended Price]),,ASC)
 
Rankv4 = RANKX(FILTER(Table_1046, Table_1046[Billing Customer Number]=EARLIER(Table_1046[Billing Customer Number])), SUM(Table_1046[Extended Price]),,DESC)

@Anonymous share the sample data in excel using one drive/google drive and i will send you the solution. Remove any sensitive information.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@Anonymous here is dax expression as a measure, you can change asc or desc, based on your needs.

 

Rank = RANKX( ALL( Sheet1[Billing Company Name]), [Ext Price], , ASC)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Unfortunately still no dice:

 

Rank v3 = RANKX(ALL(Table_1046[Billing Company Name]), [Parts Sales], , DESC)
 
Produces:

RankX Help 3.JPG
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 It's all a rank of 1 except for the last few observations, which are negative values, and those are all rank 383. 
 
Given that this doesn't seem to be working well this way, is there a way of using the TopN filter and generating a rank column from that? Thanks again for your help 
 
Parts Sales is just:
Parts Sales = SUM(Table_1046[Extended Price])

@Anonymous are you adding rank as a new column or measure? It should be measure.

 

attached file is create from your sample data.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Created as measure. It definitely works perfectly on your attachment. I'll do some more digging to see what could be interfering. Thanks again for your help. I really appreciate it

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.