March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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 | ||
Name | Date | Amount |
John | 22/04/2019 | 200 |
George | 06/04/2019 | 200 |
Paul | 02/04/2019 | 200 |
George | 31/03/2019 | 200 |
Paul | 28/03/2019 | 200 |
George | 25/03/2019 | 200 |
Paul | 19/02/2019 | 200 |
John | 05/01/2019 | 200 |
George | 01/01/2019 | 200 |
Sales Rep | ||
Name | Client | Date of Assign |
C | George | 25/04/2019 |
B | John | 18/04/2019 |
C | John | 05/04/2019 |
B | Paul | 01/04/2019 |
A | Paul | 15/03/2019 |
B | George | 25/02/2019 |
C | Paul | 20/02/2019 |
A | John | 06/01/2019 |
A | George | 02/01/2019 |
Sales Rep | Jan-19 | Feb-19 | Mar-19 | Apr-19 |
A | 1 | |||
B | 1 | 1 | ||
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?
Solved! Go to Solution.
@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.
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?
@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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
143 | |
97 | |
79 | |
68 |