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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Samcooke
Frequent Visitor

Date Diff between two tables

Hi I am a longtime Tableau user that is moving our customer base over to Power Bi. In Tableau one of the key calculations I used was Date Diff using two different tables. Essentially comparing counting days between a start date in one table and an enda date in another. But I am really having trouble replicating this in Power Bi. When I add the query DATEDIFF('Dates Table'[Start Date],'Dates Table'[End Date],MONTH) only the options for the first table appear. The 2nd table doesn't come up at all. Are you only able to compare two dates in a sigle table? Or am I am idiot and doing it wrong? 

3 REPLIES 3
v-yalanwu-msft
Community Support
Community Support

Hi, @Samcooke ;

First of all, if the date is in two tables, is there a relationship between the two tables?
You can try this measure:

measure =
DATEDIFF ( MAX ( 'table1'[date] ), MAX ( 'table2'[date] ), DAY )

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Greg_Deckler
Community Champion
Community Champion

@Samcooke I recommend not using DAX TI functions like DATEDIFF. All you have to do is get your two dates into variables and essentially subtract them like this:

Measure =
  VAR __Date1 = // some DAX to get your date in first table
  VAR __DAte2 = // some DAX to get your date in second table
RETURN
  ( __Date1 - __Date2 ) * 1. // this just makes sure you get a number value back, set your data type to Whole number.

Dates in DAX are a decimal number where the integer portion is the number of days since December 30th, 1899 and the decimal portion is fraction of a day 24/60/60.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks so much for commenting. I am still struggling. How to you get your dates into variables?

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.