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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Vtomsons
Helper I
Helper I

Calculate time between two dates

Hi,

 

Trying to do a simple calculation of days between two dates but although their are no syntax errors in my custom column and error "Expression Error: The name "DATEDIFF" wasn't recognized. Make sure its spelled correctly" comes up. Here's my formula:

 

DATEDIFF(MIN( Calendar[Enrollment date.Current Registration Status Date] ), MAX( Calendar[Last Accessed]), DAY)

 

I joined two separate tables so that my dates are in the same Query but I don't think that's the issue. What am I doing wrong?

 

Thanks,

 

Val

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

(MIN( Calendar[Enrollment date.Current Registration Status Date] ) - MAX( Calendar[Last Accessed]) * 1.



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...

View solution in original post

v-kelly-msft
Community Support
Community Support

Hi @Vtomsons

 

If it needs to be done in power query,using below M code:

 

Custom = Duration.Days([Date2]-[Date])

 

And you will see:

Annotation 2020-04-21 133719.png

 

If it is done in report view,using below dax expression to create a measure:

 

Measure = DATEDIFF(SELECTEDVALUE('Table'[Date2]),SELECTEDVALUE('Table'[Date]),DAY)

 

And you will see:

Annotation 2020-04-21 134524.png

Or you can create a calculated column as below:

 

Column = DATEDIFF('Table'[Date],'Table'[Date2],DAY)

 

And you will see:

Annotation 2020-04-21 134721.png

 

Hope the above is what you need.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

View solution in original post

6 REPLIES 6
v-kelly-msft
Community Support
Community Support

Hi @Vtomsons

 

If it needs to be done in power query,using below M code:

 

Custom = Duration.Days([Date2]-[Date])

 

And you will see:

Annotation 2020-04-21 133719.png

 

If it is done in report view,using below dax expression to create a measure:

 

Measure = DATEDIFF(SELECTEDVALUE('Table'[Date2]),SELECTEDVALUE('Table'[Date]),DAY)

 

And you will see:

Annotation 2020-04-21 134524.png

Or you can create a calculated column as below:

 

Column = DATEDIFF('Table'[Date],'Table'[Date2],DAY)

 

And you will see:

Annotation 2020-04-21 134721.png

 

Hope the above is what you need.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

Thanks fellas for the insight. New to all this so it will get easier...I hope.

Greg_Deckler
Community Champion
Community Champion

(MIN( Calendar[Enrollment date.Current Registration Status Date] ) - MAX( Calendar[Last Accessed]) * 1.



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...

Still getting the error"the name MIN wasn't recognized. Make sure its spelled correctly"

 

Do these two date columns need to be formatted some way? I have them in the date/time

And make sure that you are somewhere that you should be entering DAX code, and not in Query Editor.



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...

Oh, dude,

Measure = (MIN( Calendar[Enrollment date.Current Registration Status Date] ) - MAX( Calendar[Last Accessed]) * 1.


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...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.