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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
DanAub
New Member

DAX query comparing dates across tables

I have a table Projects like this

Project

Start Date

 

This has a many to one relationship with the table Milestones like this

Project

Milestone Name

Milestone Date

 

I want to compare Start Date in the Projects table to Milestone Date in the Milestones table where Milestone Name = “Example”. If they are the same return “Same” if they are different return “Diff”

 

I’ve tried writing this in Dax but I just can’t figure it out – can anyone help?

1 ACCEPTED SOLUTION
v-jialluo-msft
Community Support
Community Support

Hi @DanAub ,

 

Please follow these steps:

(1)This is my test data :

vjialluomsft_0-1667371003304.png

 

vjialluomsft_1-1667371003307.png

 

(2) Create a measure to judgment

judgment =
VAR _time =
    MAXX (
        FILTER ( Milestones, Milestones[Milestone Name] = "Example" ),
        Milestones[Milestone Date]
    )
VAR _time2 =
    MAXX (
        FILTER ( Projects, Projects[Porject] = MAX ( Milestones[Project] ) ),
        Projects[StarDate]
    )
RETURN
    IF ( _time = _time2, "Same", "Diff" )

(3) The result is as follows :

vjialluomsft_2-1667371003310.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the question.

 

Best Regards,

Gallen Luo

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

View solution in original post

2 REPLIES 2
v-jialluo-msft
Community Support
Community Support

Hi @DanAub ,

 

Please follow these steps:

(1)This is my test data :

vjialluomsft_0-1667371003304.png

 

vjialluomsft_1-1667371003307.png

 

(2) Create a measure to judgment

judgment =
VAR _time =
    MAXX (
        FILTER ( Milestones, Milestones[Milestone Name] = "Example" ),
        Milestones[Milestone Date]
    )
VAR _time2 =
    MAXX (
        FILTER ( Projects, Projects[Porject] = MAX ( Milestones[Project] ) ),
        Projects[StarDate]
    )
RETURN
    IF ( _time = _time2, "Same", "Diff" )

(3) The result is as follows :

vjialluomsft_2-1667371003310.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the question.

 

Best Regards,

Gallen Luo

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

wdx223_Daniel
Super User
Super User

CalculatedColumn=IF(MINX(FILTER(RELATEDTABLE(Milestones),Milestones[Milestone Name]="Example"),Milestones[Milestone Date])=Projects[Start Date],"Same","Diff")

Measure=VAR _sd=MAX(Projects[Start Date]) RETURN IF(CALCULATE(MIN(Milestones[Milestone Date]),Milestones[Milestone Name]="Example")=_sd,"Same","Diff")

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.