Forum Discussion
atarasov
6 years agoNew Member
Time in State
Hi, I have a column "Active" that can have two values TRUE or FALSE. I want to log time in state (days: hours: minutes) for TRUE or FALSE values in another column "TimeInState" and reset the cl...
az38
6 years agoCommunity Champion
Hi atarasov
If you have a Time column near the State column you could create a measure
TimeInState =
var _lastPrevState = calculate(MAX(Table[Time]), FILTER(ALL(Table), Table[State] <> SELECTEDVALUE(Table[State]) && Table[Time] < SELECTEDVALUE(Table[Time]) ) )
var _firstActiveState = calculate(MIN(Table[Time]), FILTER(ALL(Table), Table[State] = SELECTEDVALUE(Table[State]) && Table[Time] > _lastPrevState ) )
RETURN
DATEDIFF(_firstActiveState , SELECTEDVALUE(Table[Time]), MINUTE)