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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
PaulDBrown
Community Champion
Community Champion

Calculated column for RANK by product and person

Good morning,

 

Can someone help me with this? I am trying to create a calculated column which creates a rank based on product by sales person. The rank itself establishes the order by date. In other words, a sales person has a number of products which they sell consecutively: for example, "James" sells product "A" from the 25 May until 1st June, and then moves onto product "F" for a few days and then another product (etc). What I am interested is in establishing the order by date a person has sold each product.

 

I have suceeded in establishing the total order of products sold using the RANK.Q function with the related date, but I can't seem to find the way to establish this order by person and product.

 

This is the original table:

 

DateMin date Product and sales personProductSales PersonRank by Product min Date 
27/05/2019 0:0027/05/2019 0:00AJames1 
28/05/2019 0:0027/05/2019 0:00AJames1 
29/05/2019 0:0027/05/2019 0:00AJames1 
30/05/2019 0:0027/05/2019 0:00AJames1 
31/05/2019 0:0027/05/2019 0:00AJames1 
01/06/2019 0:0027/05/2019 0:00AJames1 
01/06/2019 0:0001/06/2019 0:00APeter7 
02/06/2019 0:0001/06/2019 0:00APeter7 
02/06/2019 0:0002/06/2019 0:00FJames13 
03/06/2019 0:0001/06/2019 0:00APeter7 
03/06/2019 0:0002/06/2019 0:00FJames13 
04/06/2019 0:0001/06/2019 0:00APeter7 
04/06/2019 0:0002/06/2019 0:00FJames13 
05/06/2019 0:0001/06/2019 0:00APeter7 
05/06/2019 0:0002/06/2019 0:00FJames13 
06/06/2019 0:0006/06/2019 0:00AAna19 
06/06/2019 0:0001/06/2019 0:00APeter7 
06/06/2019 0:0002/06/2019 0:00FJames13 
07/06/2019 0:0006/06/2019 0:00AAna19 
07/06/2019 0:0007/06/2019 0:00BPeter25 
07/06/2019 0:0002/06/2019 0:00FJames13 
08/06/2019 0:0006/06/2019 0:00AAna19 
08/06/2019 0:0007/06/2019 0:00BPeter25 
08/06/2019 0:0008/06/2019 0:00CJames31 
09/06/2019 0:0006/06/2019 0:00AAna19 
09/06/2019 0:0007/06/2019 0:00BPeter25 
09/06/2019 0:0008/06/2019 0:00CJames31 
10/06/2019 0:0006/06/2019 0:00AAna19 
10/06/2019 0:0007/06/2019 0:00BPeter25 
10/06/2019 0:0008/06/2019 0:00CJames31 
11/06/2019 0:0006/06/2019 0:00AAna19 
11/06/2019 0:0007/06/2019 0:00BPeter25 
11/06/2019 0:0008/06/2019 0:00CJames31 
12/06/2019 0:0007/06/2019 0:00BPeter25 
12/06/2019 0:0008/06/2019 0:00CJames31 
12/06/2019 0:0012/06/2019 0:00FAna36 
13/06/2019 0:0013/06/2019 0:00CPeter42 
13/06/2019 0:0012/06/2019 0:00FAna36 
13/06/2019 0:0013/06/2019 0:00GJames42 
14/06/2019 0:0013/06/2019 0:00CPeter42 
14/06/2019 0:0012/06/2019 0:00FAna36 
14/06/2019 0:0013/06/2019 0:00GJames42 
15/06/2019 0:0013/06/2019 0:00CPeter42 
15/06/2019 0:0012/06/2019 0:00FAna36 
15/06/2019 0:0013/06/2019 0:00GJames42 
16/06/2019 0:0013/06/2019 0:00CPeter42 
16/06/2019 0:0012/06/2019 0:00FAna36 
16/06/2019 0:0013/06/2019 0:00GJames42 
17/06/2019 0:0013/06/2019 0:00CPeter42 
17/06/2019 0:0012/06/2019 0:00FAna36 
17/06/2019 0:0013/06/2019 0:00GJames42 
18/06/2019 0:0018/06/2019 0:00CAna52 
      
     

 

And what I'm trying to get is the final column ("expected ranking")

 

rank column.JPG

 

 

Thanks!

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






1 ACCEPTED SOLUTION

hi @PaulDBrown 

For this case, you could use EARLIER Function in the formula as below:

Column 2 = 
RANKX(FILTER('Table','Table'[Sales Person]=EARLIER('Table'[Sales Person])),'Table'[Min date Product and sales person],,ASC,Dense)

https://docs.microsoft.com/en-us/dax/earlier-function-dax

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@PaulDBrown 

Column = 
VAR _name = 'Table'[Sales Person]
RETURN RANKX(FILTER('Table','Table'[Sales Person]=_name),'Table'[Min date Product and sales person],,ASC,Dense)

please create a calculated column 

@Anonymous 

 

Thanks a million! worked like a charm!

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






hi @PaulDBrown 

For this case, you could use EARLIER Function in the formula as below:

Column 2 = 
RANKX(FILTER('Table','Table'[Sales Person]=EARLIER('Table'[Sales Person])),'Table'[Min date Product and sales person],,ASC,Dense)

https://docs.microsoft.com/en-us/dax/earlier-function-dax

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.