Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi All,
I am calculating the duration between planned and actual inbound datetime. I am using the dateiff formula for this and I'm showing the output in this way : 1 days 2 hours 20 minutes. When the actual arival is earlier than planned the calculation will not work. It only working correctly when I use DATEDIFF(average(TBL_SHIPMENTS[Planned DateTime of Arrival]),average(TBL_SHIPMENTS[ACTUAL_ARRIVAL]),SECOND) but I want to see in this way 1 days 2 hours 20 minutes
Solved! Go to Solution.
Hi, @BYENER
According to the data you provided, there should be a difference of about 13 hours. To avoid the time becoming negative, you can add the function ABS(). https://docs.microsoft.com/en-us/dax/abs-function-dax
Measure =
var vSeconds = ABS(DATEDIFF(average(TBL_SHIPMENTS[Planned DateTime of Arrival]),average(TBL_SHIPMENTS[ACTUAL_ARRIVAL]),SECOND))
var vMinutes=int( vSeconds/60)
var vRemainingSeconds=MOD(vSeconds, 60)
var vHours=INT(vMinutes/60)
var vRemainingMinutes=MOD(vMinutes,60)
var vDays=INT(vHours/24)
var vRemainingHours=MOD(vHours,24)
return
vDays&" Days & "&
vRemainingHours&" Hours & "&
vRemainingMinutes&" Minutes & "&
vRemainingSeconds& " Seconds"
Does this match the output you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @BYENER
According to the data you provided, there should be a difference of about 13 hours. To avoid the time becoming negative, you can add the function ABS(). https://docs.microsoft.com/en-us/dax/abs-function-dax
Measure =
var vSeconds = ABS(DATEDIFF(average(TBL_SHIPMENTS[Planned DateTime of Arrival]),average(TBL_SHIPMENTS[ACTUAL_ARRIVAL]),SECOND))
var vMinutes=int( vSeconds/60)
var vRemainingSeconds=MOD(vSeconds, 60)
var vHours=INT(vMinutes/60)
var vRemainingMinutes=MOD(vMinutes,60)
var vDays=INT(vHours/24)
var vRemainingHours=MOD(vHours,24)
return
vDays&" Days & "&
vRemainingHours&" Hours & "&
vRemainingMinutes&" Minutes & "&
vRemainingSeconds& " Seconds"
Does this match the output you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
68 | |
68 | |
40 | |
29 | |
26 |
User | Count |
---|---|
88 | |
49 | |
45 | |
38 | |
37 |