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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Lookup with IF Condition for a Date columns

Hello,

I need help to add the Calculated Recovery Date in the Table 2 using DAX command.

Logic for Recovery Date: First it should pick the Table2[Rec Date], if Table2[Rec Date] is Null, then do a lookup on Table1[AccountingDate] and pick the MAX Table2[RecDate] group by AccountID.

Table1:

Account IDAccountingDate
101-02-2020
101-03-2020
201-04-2020
201-05-2020
301-06-2020
401-07-2020
501-08-2020
601-05-2020
701-06-2020
701-07-2020

 

Table2:

Account IDRecDateRecoveryDate
101-02-202101-02-2021
2 01-05-2020
301-04-202101-04-2021
4 01-07-2020
501-06-202101-06-2021
601-07-202101-07-2021
701-08-202101-08-2021

 

1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @Anonymous ,

 

How about:

Calculated Column =
IF ( Table2[RecDate] = BLANK(), MAXX ( FILTER ( Table1, Table1[Account ID] = Table2[Account ID]), Table1[AccountingDate] ), Table2[RecDate] )

 

Does this work? 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

@tackytechtom 's calculated column is good.

You could also create a measure.

Calculated Recovery Date = IF(ISBLANK(MAX('Table2'[RecDate])),MAX('Table1'[AccountingDate]),MAX('Table2'[RecDate]))

vstephenmsft_0-1649923246947.png

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

tackytechtom
Super User
Super User

Hi @Anonymous ,

 

How about:

Calculated Column =
IF ( Table2[RecDate] = BLANK(), MAXX ( FILTER ( Table1, Table1[Account ID] = Table2[Account ID]), Table1[AccountingDate] ), Table2[RecDate] )

 

Does this work? 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Kudoed Authors