Forum Discussion
Finding difference in hours between two dates.
- 9 years ago
Hi Dude ,
Did u tried this one ,
Duration3 = if ( Isblank('prod agenttask'[TaskStartTime])=true() || Isblank('prod agenttask'[TaskEndTime])=true ||
'prod agenttask'[TaskStartTime] > 'prod agenttask'[TaskEndTime],
Blank(),
DATEDIFF ( 'prod agenttask'[TaskStartTime], 'prod agenttask'[TaskEndTime], MINUTE )
)
Am sure it will help u .
Note :
Check Both Date column Data Type.
If not solve your prob share your data i will help uuuuuu
- 9 years ago
This is the limitation of the DATEDIFF() function in DAX. An error is returned if start_date is larger than end_date. For more details, please see: DATEDIFF Function (DAX). So in your scenario, you have to apply condition (like IF statement) to make the end date larger than start date.
Regards,
Yes. It turns out that there are end dates that preceed start dates. But why does Power BI fail on that? Wouldn't if just produce a negative number?
unfortunatley it doesn't return negative number if end date is earlier than start date, but you can add login in your if condition
if end date < start date then -(datediff(enddate, startdate, minute)) else datediff(start date, enddate, minute)
This will give you negative number when end date is earlier than start date and otherwise you will get positive number. Hope it is helpful.