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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
data_guy_87
Frequent Visitor

Calculate total hours each ID spends in each status

Hello, I have looked through the forums but am not quite finding my situation...

 

I have the sample table below, which tracks multiple IDs moving through various statuses in a process. I would like to create a calculated column (TOTAL_TIME_IN_STATUS) which is the far right column below. I have populated a few expected results on the two sets of IDs. This is based on the next ID update record's timestamp. 

 

I might also want the option to either show total minutes or total hours for each status record. Any help is greatly appreciated!

 

IDTIME_STAMPSTATUSTOTAL_TIME_IN_STATUS (minutes)
INPR0006238-110/28/2025 17:02DISC_INITIATION 32
INPR0006238-110/28/2025 17:34DISC_QE 
INPR0006238-110/29/2025 6:36MRB_T1 
INPR0006238-110/29/2025 6:36DISC_QE 
INPR0006238-110/29/2025 10:31DISC_QE 
INPR0006238-110/29/2025 10:31MRB_T1 
INPR0006238-110/29/2025 10:38DISC_INITIATION 
INPR0006238-110/29/2025 10:38DISC_QE 
INPR0006238-110/29/2025 11:01DISC_QE 
INPR0006238-110/29/2025 11:01DISC_INITIATION 
INPR0006238-110/29/2025 12:42MRB_T1 
INPR0006238-110/29/2025 12:42DISC_QE 
INPR0006073-41/6/2026 15:02DISC_QE 2
INPR0006073-41/6/2026 15:04DISC_INITIATION 0
INPR0006073-41/6/2026 15:04DISC_QE 104
INPR0006073-41/8/2026 16:58DISC_QE 
INPR0006073-41/8/2026 16:58DISC_INITIATION 
INPR0006073-41/9/2026 8:10MRB_T1 
INPR0006073-41/9/2026 8:10DISC_QE 
INPR0006073-41/15/2026 7:18DISC_QE 
INPR0006073-41/15/2026 7:18MRB_T1 
INPR0006073-41/15/2026 7:53DISC_INITIATION 
INPR0006073-41/15/2026 7:53DISC_QE 
INPR0006073-41/15/2026 8:02DISC_QE 
INPR0006073-41/15/2026 8:02DISC_INITIATION 
INPR0006073-41/15/2026 8:47MRB_T1 
INPR0006073-41/15/2026 8:47DISC_QE 
INPR0006073-41/19/2026 10:21MRB_STRESS 
INPR0006073-41/19/2026 10:21MRB_T1 
INPR0006238-11/19/2026 10:22MRB_T1 
INPR0006238-11/19/2026 10:22MRB_STRESS 
INPR0006073-41/19/2026 11:57MRB_T2 
INPR0006073-41/19/2026 11:57MRB_STRESS 
INPR0006073-41/19/2026 12:02CR 
INPR0006073-41/19/2026 12:02MRB_T2 
INPR0006238-11/19/2026 12:25MRB_T2 
INPR0006238-11/19/2026 12:25MRB_STRESS 
INPR0006238-11/19/2026 12:38CR 
INPR0006238-11/19/2026 12:38MRB_T2 
1 ACCEPTED SOLUTION
FreemanZ
Community Champion
Community Champion

hi @data_guy_87 ,

 

Try like:

1) add a index column in Power Query. There are duplicate timestamps, otherwise we could rely on timestamp column to locate next rows. 
How: https://learn.microsoft.com/en-us/power-query/add-index-column


2) add a calculated column like:

Minutes = 
VAR _id = data[ID]
VAR _index = data[Index]
VAR _time = data[TIME_STAMP]
VAR _next = 
MINX(
    FILTER(
        data,
        data[ID]=_id
            &&data[Index]>_index
    ),
    data[TIME_STAMP]
)
VAR _result = DATEDIFF(_time, _next, MINUTE)
RETURN  _result

 

it works like:

FreemanZ_0-1769140665059.png

View solution in original post

1 REPLY 1
FreemanZ
Community Champion
Community Champion

hi @data_guy_87 ,

 

Try like:

1) add a index column in Power Query. There are duplicate timestamps, otherwise we could rely on timestamp column to locate next rows. 
How: https://learn.microsoft.com/en-us/power-query/add-index-column


2) add a calculated column like:

Minutes = 
VAR _id = data[ID]
VAR _index = data[Index]
VAR _time = data[TIME_STAMP]
VAR _next = 
MINX(
    FILTER(
        data,
        data[ID]=_id
            &&data[Index]>_index
    ),
    data[TIME_STAMP]
)
VAR _result = DATEDIFF(_time, _next, MINUTE)
RETURN  _result

 

it works like:

FreemanZ_0-1769140665059.png

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.