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

Comparing Dates between two different tables

I am trying to create a new custom measure that will compare two dates from two different tables. This is how the model has been defined

 

VinitGohil1976_0-1743429292556.png

I need to compare the Agreement[Agreement Activated Date] to the Policy Date which is a calculated column with the following definition:

 

Policy Date = IF(ISBLANK(Policy[Policy Start Date]), DATE(1900, 1, 1), Policy[Policy Start Date]).
I created this MaxDatemeasure but i dont think this actually compares the activated and start dates by row
 VinitGohil1976_2-1743429585604.png
VinitGohil1976_1-1743429501053.png

Is there a way to compare the dates by row so that it can take the maximum of the two dates on the row and uses that to set as the new maxdate?

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could create a calculated column in the agreement snapshot fact table like

Cancellation Due Date =
MAX (
    RELATED ( Agreement[AgreementActivatedDate] ),
    RELATED ( Policy[Policy Date] )
) + 60

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

You could create a calculated column in the agreement snapshot fact table like

Cancellation Due Date =
MAX (
    RELATED ( Agreement[AgreementActivatedDate] ),
    RELATED ( Policy[Policy Date] )
) + 60
Deku
Super User
Super User

Max( max( Agreement[Agreement Activated Date]), max(Policy[Policy Date]))


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

That also causes the same issue. I am basically trying to define this Sql logic in Power Bi

 

date_add(IF(pol.PolicyStartDate > agr.AgreementActivatedDate, pol.PolicyStartDate, agr.AgreementActivatedDate), 60) as CancellationDueDate
 
I tried with IF clauses and SWITCH statements also but i think the issue is more with the model than it is with the dates. If there are any further suggestions, i am willing to try any... thanks

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.