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

Date difference between two columns in two tables

I'm trying to calculate the difference, i.e. the age between two date columns, in two different tables Without any luck...

 

Can someone assist?? 

6 REPLIES 6
KayceVC
Helper II
Helper II

Have you tried using DATEDIFF in a calculated column?

 

Syntax: DATEDIFF(Table1[Start_Date], Table2[End-Date], interval)

 

This will throw an error if your end date is before your start date and your interval can be anything from a second to a year. 

 

Reference: DATEDIFF Function

Anonymous
Not applicable

Hi Kayce

 

I have but I can't get the datediff function to see the second table.. Do I need to have the column names the same in the two tables? 

 

I have a set of CSV files that I'm trying to trend over time. In the files is information about locked out users in AD and I have the AccountLock time stamp and what to correlate that value against the creation time stamp of the source file. I have a relationship between the two tables.

 

Excuse the dumb question but I'm new to this sort of data manipulation

Did you import the csv files into your PowerBI report? Are you creating the DATEDIFF as a calculated column or a measure? Since this is iterating over rows, it has to be done as a calcualted column, a measure will not see all the fields in your tables. Also, double check your column formatting on the date columns. It should not matter, except to the resulting value, but it's something to check.

Anonymous
Not applicable

No matter what I try I can't get the Datediff function to see the 2nd table..

In your case, it may be necessary to provide sample data and let us know the process you used to get your data into PowerBI. There is no reason you should not be able to access data from 2 different tables in a DATEDIFF. 

jdbuchanan71
Super User
Super User

Hello @Anonymous 

Can you give us an idea of how the model is constructed?  Are the tables joined together, what are the field names, etc?  A sample of the data and an expected outcome (difference in months, days, years?) would also help.

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 Solution Authors