cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
harrisonalnwick
Frequent Visitor

Determine sales lead status at time of sending an email

Hi,

I have two tables.

Table 1 tracks the lead status of a customer throughout that customers lifecycle.

 

CustomerIdDateLeadStatus
101/11/2021Prospective
110/11/2021Active
114/11/2021Pending cancellation
116/11/2021Cancelled

 

 

Table 2 tracks system generated emails that have been sent to that customer.

CustomerIdEmailSentLeadStatusAtTime
102/11/2021xx
115/11/2021xx
116/11/2021xx

 

I would like to work out what the lead status was at the time the email was sent and any help would be greatly appreciated 🙂

 

Many thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@harrisonalnwick , Create a new column in Table 2

 

New column =
var _max = maxx(filter(Table1, Table1[CustomerId] = Table2[CustomerId] && Table1[Date]<= Table2[EmailSent]), Table1[Date])
return
maxx(filter(Table1, Table1[CustomerId] = Table2[CustomerId] && Table1[Date]=_max ), Table1[LeadStatus])

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

View solution in original post

3 REPLIES 3
harrisonalnwick
Frequent Visitor

@amitchandak  Many thanks

As a follow on question, in addition to working out the lead status that the time the email was sent, how could I work out how long the lead has been in that lead status at the time that the email was sent?

harrisonalnwick
Frequent Visitor

Thank you 🙂

 

amitchandak
Super User
Super User

@harrisonalnwick , Create a new column in Table 2

 

New column =
var _max = maxx(filter(Table1, Table1[CustomerId] = Table2[CustomerId] && Table1[Date]<= Table2[EmailSent]), Table1[Date])
return
maxx(filter(Table1, Table1[CustomerId] = Table2[CustomerId] && Table1[Date]=_max ), Table1[LeadStatus])

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

Helpful resources

Announcements
Power BI Show Ep 4 Post Show Carousel.jpg

The Power BI Community Show

Shabnam Watson demos Incremental refresh & Hybrid Tables and Leila Etaati demos Charticulator.

PBI April Release 2022 768x460.png

Check it out!

Click here to read more about the April 2022 updates!

Power BI Dev Camp Session 22 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!