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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How can I measure the time spent on each state

 

Hi, 

 

I have the following data - each ID spends some time on different states that can reoccur over time. I need to calculate the time overall time spent on each state by each ID. Any suggestions will be much appreciated. Thank you.

 

1 - time spent on V, time spent on C, 

2 - time spent on V, time spent on C

 

 

IDTimestampState
18/10/2020V
28/11/2020C
18/12/2020C
28/13/2020D
18/14/2020C
28/15/2020V
18/16/2020C
18/17/2020C
28/18/2020V
28/19/2020V
2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create a measure

Measure =
VAR mind =
    CALCULATE (
        MIN ( 'Table'[Timestamp] ),
        ALLEXCEPT ( 'Table', 'Table'[ID], 'Table'[State] )
    )
VAR maxd =
    CALCULATE (
        MAX ( 'Table'[Timestamp] ),
        ALLEXCEPT ( 'Table', 'Table'[ID], 'Table'[State] )
    )
RETURN
    DATEDIFF ( mind, maxd, DAY ) + 1

Capture15.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , You can have diff between two rows  as a new column

datediff(maxx(filter(Table, [Timestamp] <[Timestamp] ),[Timestamp]),[Timestamp],Minute)

 

You can use that for more calculations

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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