Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
atarasov
New 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 clock when state changes. Is it possible to achive with PowerBI and if yes, what is the solution?

 

Thank you.

5 REPLIES 5
V-lianl-msft
Community Support
Community Support

Hi @atarasov ,

 

Based on your description, what you want to achieve is to calculate the duration of a state. When it updates the state, it will reset the time to zero.

Unfortunately, I'm afraid it's hard to achieve according to my attempt.

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

az38
Community Champion
Community 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)

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Thank you, what is in Time column? 

az38
Community Champion
Community Champion

@atarasov 

what column do you want to store log datetime in?


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Thanks, I did what you have suggested, but both columns have no values in it.

 

What am I missing? 

 

Thanks.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors