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
Shelley
Continued Contributor
Continued Contributor

Need help with RANKX by Customer

I'm trying to Rank Customer IDs by the Total Hours Delivered to them. Here's the formula I'm trying:

 

Rank Hours = RANKX(ALL('CustomerTable'[CustomerID]), 'ServiceTicketTable'[Total Hours Delivered])

 

This results in all customers with a rank of 1.

 

1 Cust A 8 hours

1 Cust B .5 hours

1 Cust C 3 hours

 

What the heck am I missing?

1 ACCEPTED SOLUTION

Thanks for your confirmation on my formula.

 

I spent hours trying to get this to work with the relationship between customer and hours through a Link Table. I found this awesome post and the line that says "... with the filtering context of these two tables being related to each other (there’s a relationship between Projects and Budget thru ProjIDs)." Aha! I connected this customer list directly to the hours table, with the RANKX formula in the customer table and it worked! Then, I thought about the Link table and when I put the RANKX formula in the Link Table it also worked because the Link Table has a direct connection to the Hours table! Both formulas work even using an inactive relationship as long as the customer table is directly linked to the hours table.

 

The only thing I changed in my formula from above was adding descending order (the higher the hours, the better the rank):

Rank Hours = RANKX(ALL('CustomerTable'[CustomerID]), 'ServiceTicketTable'[Total Hours Delivered] , , DESC )

View solution in original post

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

 

Your formula is correct.  Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks for your confirmation on my formula.

 

I spent hours trying to get this to work with the relationship between customer and hours through a Link Table. I found this awesome post and the line that says "... with the filtering context of these two tables being related to each other (there’s a relationship between Projects and Budget thru ProjIDs)." Aha! I connected this customer list directly to the hours table, with the RANKX formula in the customer table and it worked! Then, I thought about the Link table and when I put the RANKX formula in the Link Table it also worked because the Link Table has a direct connection to the Hours table! Both formulas work even using an inactive relationship as long as the customer table is directly linked to the hours table.

 

The only thing I changed in my formula from above was adding descending order (the higher the hours, the better the rank):

Rank Hours = RANKX(ALL('CustomerTable'[CustomerID]), 'ServiceTicketTable'[Total Hours Delivered] , , DESC )

I wish I could, I really need and appreciate the help, but my company doesn't allow me to share data. It would take me a long time to mock it up with fake data. Unless you have any easy way to do this?

 

Rfranca
Resolver IV
Resolver IV

hi,  @Shelley

 

Is 'ServiceTicketTable' [Total Hours Delivered] formatted as numeric?

 

Shelley
Continued Contributor
Continued Contributor

It was format "General" I changed it to "Decimal Number", but nothing changed in the results.

 

Formula should be:
Rank Hours = RANKX('CustomerTable'[CustomerID], 'ServiceTicketTable'[Total Hours Delivered])

Shelley
Continued Contributor
Continued Contributor

Thanks for the help. When I try this, I receive an error that says "A single value for Customer ID cannot be determined." This is odd because there are no duplicate Customer IDs in this table.

 

Oh, it is actually even more simple:

 

Rank Hours = RANKX('CustomerTable', 'ServiceTicketTable'[Total Hours Delivered])

 

This should work

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.