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
prashanth0626
Frequent Visitor

Find previous record in last 30 days

I have a table with 3 rows (MobilePhone, LeadSource,CreatedDate). I am trying to create a New column which basically displays the LeadSource if exist with the same phone number in the last 30 days else use the current Lead source. Any help how do i go ahead with this? Thanks! Capture.PNG

2 ACCEPTED SOLUTIONS
az38
Community Champion
Community Champion

Hi @prashanth0626 

try a column

Column = 
var _findVal = CALCULATE(FIRSTNONBLANK(Table[LeadSource]), FILTER(ALL(Table), Table[MobilePhone]=EARLIER(Table[MobilePhone]) && DATEDIFF(Table[CreatedDate], Today(), DAY) <=30) )
RETURN
if(isblank(_findVal ), Table[LeadSource], _findVal )

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

@prashanth0626 

try

Prev Lead Source =
var _findVal = CALCULATE(FIRSTNONBLANK('Lead'[LeadSource],1), FILTER(ALL('Lead'), 'Lead'[MobilePhone]=EARLIER('Lead'[MobilePhone]) && DATEDIFF('Lead'[CreatedDate], EARLIER('Lead'[CreatedDate]), DAY) <=30) )

RETURN

if(isblank(_findVal ), 'Lead'[LeadSource], _findVal)    

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

4 REPLIES 4
az38
Community Champion
Community Champion

Hi @prashanth0626 

try a column

Column = 
var _findVal = CALCULATE(FIRSTNONBLANK(Table[LeadSource]), FILTER(ALL(Table), Table[MobilePhone]=EARLIER(Table[MobilePhone]) && DATEDIFF(Table[CreatedDate], Today(), DAY) <=30) )
RETURN
if(isblank(_findVal ), Table[LeadSource], _findVal )

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

How do i ammend it if i want the Leadsource for last 30 days from the CreatedDate?

@prashanth0626 

try

Prev Lead Source =
var _findVal = CALCULATE(FIRSTNONBLANK('Lead'[LeadSource],1), FILTER(ALL('Lead'), 'Lead'[MobilePhone]=EARLIER('Lead'[MobilePhone]) && DATEDIFF('Lead'[CreatedDate], EARLIER('Lead'[CreatedDate]), DAY) <=30) )

RETURN

if(isblank(_findVal ), 'Lead'[LeadSource], _findVal)    

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

That actually worked! Thanks!

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.