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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
razmochaev
Helper I
Helper I

Calculate Leads' Sales After First Contact

Hi everyone.

I'm quite new into DAX and I'm struggling with the following task.

I have two dimension tables -dimClients and dimDates, - and two fact tables: factSales and factCalls.

 

factCalls contains all the calls of potential leads, and factSales - all the sales.

 

I want to calculate all the sales that were generated by these leads after the date they called.

I use CALCULATE function (calculate (sum(factSales[SalesAmount])). I  suggest that I need to apply two filters on dim tables:

1. filter on dimDate table - to keep only dates after the date of call stored in factCalls;

2. filter on imClients table - to keep only those clientID that exist in factCalls table.

 

But I cannot come up with the right formula.

 

Any hint will be much appreciated.

 

1 ACCEPTED SOLUTION

Hi, smoupre.

Thank you for the reply and for the hint you gave. I've come up with the solution that does the work:

LeadSales = CALCULATE([factSales];filter(dimClients;CONTAINS(factCalls;factCalls[ClientID];dimClients[ClientID]));filter(dimDates;dimDates[Date].[Date]>=MIN(factCalls[Date])))

I modified the formula you suggested as I needed only those sales, that occurred after the initial contact with the lead, i.e. starting from the date the lead appeared in the factCalls table.

And CONTAINS function does a great job filtering only those clients that appear in factCalls table.

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

Still thinking through the second part. I believe the first part you could handle with something like:

 

CALCULATE(SUM(factSales[SalesAmount]),FILTER(factSales,factSales[date]>MAX(factCalls[date])))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi, smoupre.

Thank you for the reply and for the hint you gave. I've come up with the solution that does the work:

LeadSales = CALCULATE([factSales];filter(dimClients;CONTAINS(factCalls;factCalls[ClientID];dimClients[ClientID]));filter(dimDates;dimDates[Date].[Date]>=MIN(factCalls[Date])))

I modified the formula you suggested as I needed only those sales, that occurred after the initial contact with the lead, i.e. starting from the date the lead appeared in the factCalls table.

And CONTAINS function does a great job filtering only those clients that appear in factCalls table.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.