Forum Discussion
Calculate time difference between 2 dates/time only working hours and exclude weekends and holidays
Hi Anonymous ,
I do not understand why the 25th 16:00 to 28th 11:00 is 4 hours. And I got 19 hours after calculation.
I have created a simple sample, please refer to it to see if it helps you.
Create a measure.
Measure =
VAR _start =
MAX ( Sheet2[date] )
VAR _if_start =
IF ( MAX ( Sheet2[_count] ) = BLANK (), BLANK (), _start )
VAR _end =
CALCULATE (
MAX ( Sheet2[date] ),
FILTER (
ALL ( Sheet2 ),
Sheet2[column-]
= SELECTEDVALUE ( Sheet2[column-] ) - 1
&& Sheet2[_count] <> BLANK ()
)
)
VAR _if_end =
IF ( MAX ( Sheet2[_count] ) = BLANK (), BLANK (), _end )
RETURN
_if_start - _if_end
I have also found an interesting video, please refer to it to see if it helps you.
PowerBI: Calculate business/working days between two dates in a new column
If I have misunderstood your meaning, please provide your pbix file without privacy information and desired output.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous4 years agoNot applicable
"I do not understand why the 25th 16:00 to 28th 11:00 is 4 hours. "
It is because the workday ends on 17:00 on friday. So that is 1 hour.
Then the workday starts again at 8:00 on monday untill 11:00. So that is 3 hours.
Like this the total is 4 hours.The solution like you providede doesn't work for my case...