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

Assign client to Rep after an event

Hello Power BI specialists,

 

I would like a little bit help with the below.

 

I have two tables. A transaction table and sales rep table. The first one includes the client name, the date of transaction and the amount. The second one includes the sales rep, the client and the date of assign. 

 

I need to find out which sales rep was assign to the client the date the client repurchase a product. Then I need to create a summary with the sales rep and the count of clients who repurchase at a spesific month. 

 

See below example. 

 

Clients Purchases  
NameDateAmount
John22/04/2019200
George06/04/2019200
Paul02/04/2019200
George31/03/2019200
Paul28/03/2019200
George25/03/2019200
Paul19/02/2019200
John05/01/2019200
George01/01/2019200

 

Sales Rep  
NameClientDate of Assign
CGeorge25/04/2019
BJohn18/04/2019
CJohn05/04/2019
BPaul01/04/2019
APaul15/03/2019
BGeorge25/02/2019
CPaul20/02/2019
AJohn06/01/2019
AGeorge02/01/2019

 

Sales RepJan-19Feb-19Mar-19Apr-19
A  1 
B  11
C    

 

George made his first repurchase on 25/03.

He has been assign to sales rep B 25/02. Therefore sales rep B takes 1 on March, for George's repurchase. 

 

John made his first repurchase on 22/04.

He has been assign to sales rep B on 18/04. Therefore sales rep B takes 1 on April, for John's repurchase. 

 

How can I calculate the above with dax?

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous try following dax to add salesrep in purchase table and then it is easy to creat matrix to get count by sales rep

 

SalesRep = 
 CALCULATE( 
     VALUES( Client[Name] ), 
     TOPN( 
         1, 
         FILTER( 
             Client, 
             Client[Client] = Purchase[Name] &&
             Client[Date of Assign] < Purchase[Date]
        ), 
        Client[Date of Assign], 
        DESC 
    )
)


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.

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Does a 1 in the third table indicate the count of clients that the Sales rep takes credit for in that month?  If yes, then 4 would indicte that there were 4 clients which that sales rep gets credit for in that month?

Is my understanding correct?


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

@Anonymous try following dax to add salesrep in purchase table and then it is easy to creat matrix to get count by sales rep

 

SalesRep = 
 CALCULATE( 
     VALUES( Client[Name] ), 
     TOPN( 
         1, 
         FILTER( 
             Client, 
             Client[Client] = Purchase[Name] &&
             Client[Date of Assign] < Purchase[Date]
        ), 
        Client[Date of Assign], 
        DESC 
    )
)


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.

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.

Top Solution Authors