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
nataliesmiy1357
Helper III
Helper III

Dates in Between Format

Hello!!  I am trying to calculate a BUNCH of dates in the time period measures, but none of them are seeming to actually code.  When I type in the columns in the dax, they won't pop up.  What is the format of the value that I need to have for those dates?  Currently they are date/time and on one of the common formats.  

 

Thanks in advance.

2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @nataliesmiy1357 

 

You need to use SELECTEDVALUE so DATEDIFF knows which dates to use

 

Measure = DATEDIFF(SELECTEDVALUE('DataTable'[CreateActivityPlanStartDate]), SELECTEDVALUE('DataTable'[CreateActivityPlanEndDate]), DAY)

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

v-henryk-mstf
Community Support
Community Support

Hi @nataliesmiy1357 ,

 

According to my tests, both of the following ways can get the date difference between the start date and the end date.

M_1 = DATEDIFF(MAX('Table'[Start Date]),MAX('Table'[End Date]),DAY)
M_2 = 
var a = SELECTEDVALUE('Table'[Start Date])
var b = SELECTEDVALUE('Table'[End Date])
return
CALCULATE(DATEDIFF(a,b,DAY),ALL('Table'))

vhenrykmstf_0-1636612733238.png

If the understanding is wrong, are you able to point out the problem and provide the desired result. Looking forward to your feedback.


Best Regards,
Henry


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

4 REPLIES 4
v-henryk-mstf
Community Support
Community Support

Hi @nataliesmiy1357 ,

 

According to my tests, both of the following ways can get the date difference between the start date and the end date.

M_1 = DATEDIFF(MAX('Table'[Start Date]),MAX('Table'[End Date]),DAY)
M_2 = 
var a = SELECTEDVALUE('Table'[Start Date])
var b = SELECTEDVALUE('Table'[End Date])
return
CALCULATE(DATEDIFF(a,b,DAY),ALL('Table'))

vhenrykmstf_0-1636612733238.png

If the understanding is wrong, are you able to point out the problem and provide the desired result. Looking forward to your feedback.


Best Regards,
Henry


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

PhilipTreacy
Super User
Super User

Hi @nataliesmiy1357 

 

You need to use SELECTEDVALUE so DATEDIFF knows which dates to use

 

Measure = DATEDIFF(SELECTEDVALUE('DataTable'[CreateActivityPlanStartDate]), SELECTEDVALUE('DataTable'[CreateActivityPlanEndDate]), DAY)

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @nataliesmiy1357 

 

Need more information please, and maybe screenshots to se what you are doing.

 

If you are typing a DAX function name it should prompt you with what parameters (e.g. tables, columns) it can use.  If it isn't then I suspect you're using the wrong function at that time, or the function can't 'see' the column/table.

 

The format and data type of the column doesn't mnatter to the DAX function as you type, it only checks this when it tries to calculate.

 

Please supply data, screenshots and a detailed explanation of what you are trying to do.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Phil - This is a screenshot of my data.  So what I want to do, is do how many days in between the EndDate and the StartDate.  But when I do the DAX Difference = Datediff(......) the columns don't populate.  

 

nataliesmiy1357_0-1636414278420.png

 

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.