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.
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.
Solved! Go to Solution.
You need to use SELECTEDVALUE so DATEDIFF knows which dates to use
Measure = DATEDIFF(SELECTEDVALUE('DataTable'[CreateActivityPlanStartDate]), SELECTEDVALUE('DataTable'[CreateActivityPlanEndDate]), DAY)
Regards
Phil
Proud to be a Super User!
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'))
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.
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'))
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.
You need to use SELECTEDVALUE so DATEDIFF knows which dates to use
Measure = DATEDIFF(SELECTEDVALUE('DataTable'[CreateActivityPlanStartDate]), SELECTEDVALUE('DataTable'[CreateActivityPlanEndDate]), DAY)
Regards
Phil
Proud to be a Super User!
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
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
96 | |
80 | |
67 | |
62 |
User | Count |
---|---|
138 | |
107 | |
104 | |
82 | |
63 |