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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.