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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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