Forum Discussion
manyerukebenn
6 years agoRegular Visitor
Date Difference for two rows
I am having problems calculating date difference for the below scenario. I want to calculate the total time spent on a particular job by a mechanic. When the mechanic start and pause we should calcul...
Chthonian
6 years agoHelper III
I am a bit of an amateur and there would be a much more sophisticated way to achieve this but this solution worked for me 🙂
Job Duration =
VAR JobStart = CALCULATE(MIN(Table1[Activity Time]), Table1[Status ] = "Started")
VAR BreakStart = CALCULATE(MIN(Table1[Activity Time]), Table1[Status ] = "Paused")
VAR BreakEnd = CALCULATE(MAX(Table1[Activity Time]), Table1[Status ] = "Started")
VAR JobEnd = CALCULATE(MAX(Table1[Activity Time]), Table1[Status ] = "Stopped")
RETURN
CALCULATE(
DATEDIFF(JobStart,JobEnd,MINUTE) - DATEDIFF(BreakStart,BreakEnd,MINUTE)
)
PS: Ignore the 'DocEntry' figure, forgot to remove the quick sum calc 😁