I have been using DAX DATEDIFF statement to calculate No Days between two dates which are
Target Completion Date and Actual Completion Date
Which works all very well except now I have sometimes the Actual Completion Date is before the Target Completion Date (ie where an Action Officer performed better and completed the task before the "target" date).
However, of course, DATEDIFF doesn't like this and gives error "In DATEDIFF function, the start date cannot be greater than the end date"
Why can't this Dax function just return the negative value in this case? Is there a way we can enhance this function to return a signed integer?
Solved! Go to Solution.
Hi,
Whilst I can't answer the "why" it can't return a negative integer for dates where the start date is after the end date I can suggest you could simply handle it with a IF statement. Test your dates if the start date is greater than the end date then change the sign of the result datediff with the dates passed to the function the other way round.
DateDiffMeasure := IF ( [StartDateField] > [EndDateField], 0 - DATEDIFF ( [EndDateField], [StartDateField], DAY ), DATEDIFF ( [StartDateField], [EndDateField], DAY ) )
Might work for you?
User | Count |
---|---|
359 | |
128 | |
87 | |
84 | |
54 |
User | Count |
---|---|
410 | |
214 | |
126 | |
116 | |
112 |