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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Wirestat
Frequent Visitor

How to Find Orders Duration based on Start Stop time

Hello, how its possible to find order duration based on starting and finishing time, for example like in column duration. 

Order idFromToDuration
023:0023:03 
130699323:0323:03 
130699323:0323:06 
130699323:2223:33 
130699323:3323:33 
130699323:3423:35 
130699323:3523:37 
130699323:3823:39 
130699323:4223:43 
130699323:4323:4300:40
023:4323:44 
130530023:4423:45 
130530023:4523:46 
130530023:4723:47 
130530023:4823:49 
130530023:5423:54 
130530023:5423:55 
130530023:5623:59 
130530023:5900:00 
130530000:0000:01 
130530000:0200:03 
130530000:0300:03 
130530000:0400:04 
130530000:0400:07 
130530000:0700:07 
130530000:0700:08 
130530000:0800:0900:25
000:0900:10 
130701200:5300:54 
130701200:5400:55 
130701200:5600:58 
130701201:0201:0500:12
001:0501:05 
130703101:0501:05 
130703101:0601:06 
130703101:1101:11 
130703101:1301:14 
130703101:1901:42 
130703101:4401:45 
130703101:4501:46 
130703101:4601:4600:41
1 ACCEPTED SOLUTION

Hi @Wirestat 
Please try

Duration (Minutes) =
SUMX (
    VALUES ( 'Table'[Order ID] ),
    VAR CurrentIDTable =
        CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Order ID] ) )
    VAR FirstStart =
        MINX ( CurrentIDTable, 'Table'[From] )
    VAR LastEnd =
        MAXX ( CurrentIDTable, 'Table'[To] )
    RETURN
        DATEDIFF ( FirstStart, LastEnd, MINUTE )
)

View solution in original post

7 REPLIES 7
FreemanZ
Super User
Super User

hi @Wirestat 

try to plot a table visual  with the order id column and a measure like:

Duration = 
MAXX(
    TableName,
    TableName[To]            
)
-
MINX(
    TableName,
    TableName[From]
)

 

it worked like:

FreemanZ_0-1676972777998.png

 

your from and to columns shall include date info, with date info, you shall get the correct duration for 1305300 as well. 

tamerj1
Super User
Super User

Hi @Wirestat 

what about the gaps?

659AB584-16F7-4B2E-BBFA-40CF4B73A43A.jpeg

Hello tamerj1, the gaps shows sub orders serving, just ignore them, the goal to display duration of order from 23:03 until 23:43 which is 40 min time for order 1306993

Hi @Wirestat 
Please try

Duration (Minutes) =
SUMX (
    VALUES ( 'Table'[Order ID] ),
    VAR CurrentIDTable =
        CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Order ID] ) )
    VAR FirstStart =
        MINX ( CurrentIDTable, 'Table'[From] )
    VAR LastEnd =
        MAXX ( CurrentIDTable, 'Table'[To] )
    RETURN
        DATEDIFF ( FirstStart, LastEnd, MINUTE )
)

Thank you sir, its working!

Anonymous
Not applicable

Hi. 
Use DateDifference function to achieve the same requirement.

 

 

Minutes taken = DATEDIFF(tablename[From], tablename[To], MINUTE)

 

 

Though this will just give the minutes. 

To achieve the exact requirement, you can follow the Solution mentioned in this below link:
Solved: datediff in HH:MM format - Microsoft Power BI Community
OR
Aggregating Duration/Time - Microsoft Power BI Community

Thank you.
If my answer helps you, please mark it as solution.

 

Hi VishalJhaveri, unfortunatly this answer provide diffrance for each row, and my goal is to find duration for complete order. Thank your for affort! 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.