Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I have this data that is timed by intervals, of which state machinery is in:
TIME: STATE:
7:59 Stopped
8:00 Stopped
8:01 Moving
8:02 Moving
8:03 Stopped
I need to calculate the time spent while state = moving, and state = stopped, in hours and minutes.
Something like this: Stopped - 2:21, Moving - 3:45
Solved! Go to Solution.
Hi @TomasPac
if your data is like your sample date, you can use this measure:
Measure =
INT ( COUNT ( 'Table'[Time] ) / 60 ) & ":"
& RIGHT (
0
& COUNT ( 'Table'[Time] )
- (
INT ( COUNT ( 'Table'[Time] ) / 60 ) * 60
),
2
)
then add [State] and [Measure] to a table visual to obtain this:
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Hi @TomasPac
if your data is like your sample date, you can use this measure:
Measure =
INT ( COUNT ( 'Table'[Time] ) / 60 ) & ":"
& RIGHT (
0
& COUNT ( 'Table'[Time] )
- (
INT ( COUNT ( 'Table'[Time] ) / 60 ) * 60
),
2
)
then add [State] and [Measure] to a table visual to obtain this:
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
It is not caused by AM/PM change. I have created a dataset which has one status pr minute from 7:52 to 16:57, and the measure returns 9:06. Which means that there are some issues in your data set. Either duplicate rows or an interval with two statuses.
What about the seconds in my format?? Because the result is completely wrong for me.. In my data State = Moving shows from 2:58:24 PM till 4:57:00 PM, the calculation says that state Moving was for 8:34
As the title of your question was ...hours and minutes... and you provided sample data in the form 7:59,8:00,8:01,8:02,.., I assumed your time data where in the format hh:mm, and that the state would be updated every minute. If this is not the case, the solution I suggested will not work.
If your actual data is not like the sample data in your original post, could you please post a sample dataset which has the same properties as your actual data? Or post a excerpt from your data?
My time data format is this 8:00:00
There are many ways of doing this, I came up with one suggestion, based on the information you gave in your original post, which was hours:minutes, and taking advantage of the fact that your sample data has intervals of 1 minute. If this is not representative for your data, please post a sample dataset which is representative for your data.