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
Stewwe
Helper II
Helper II

Total running time of scantimes

Hello,

 

I hope you can help me 🙂

 

First, I have the following table:

 

TrackingcodeScantime
12345626.11.2020 18:28
12345627.11.2020 20:15
12345627.11.2020 01:02
12345626.11.2020 19:10
12345625.11.2020 00:00
98765430.11.2020 07:00
98765430.11.2020 09:17
98765430.11.2020 07:05
98765430.11.2020 11:16
98765430.11.2020 09:17

 

Now I want to get the highest and the lowest scantime for each trackingcode. After that I want to subtract each value to get the indivual runningtime for each tracking code.  At last I want to have a Measure "totalrunningtime" that sums everything up:
123456 = 27.11.2020 20:15 -  26.11.2020 18:28  = x
987654 = 30.11.2020 11:16 - 30.11.2020 07:05 =y

totalruninngtime=sum(x+y)

Puh, I hope you get the point 🙂

 

At best would be one measure that calculates everything in one step.

 

Any help kindly appreciated!

Thank you
Stewwe



 

 

1 ACCEPTED SOLUTION

Ok, now I have it!:

Time Difference = 
Time Difference =
VAR __table =
    ALLEXCEPT ( Table, Table[TrackingCode] )
RETURN
    SUMX (
        VALUES ( Table[TrackingCode] ),
        DATEDIFF (
            CALCULATE ( MAX ( Table[ScanTime] ), __table ),
            CALCULATE ( MIN ( Table[ScanTime] ), __table ),
            MINUTE
        )
    )

 Thank you!

Stewwe

 

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@Stewwe try following measure:

 

Time Difference = 
VAR __table = ALLEXCEPT ( Table, Table[TrackingCode] ) 
VAR __minTime = CALCULATE ( MIN ( Table[ScanTime] ), __table )
VAR __maxTime = CALCULATE ( MAX ( Table[ScanTime] ), __table )
RETURN
DATEDIFF ( __maxTime, __minTime, MINUTE )

 

Check my latest blog post Improve UX: Show Year in Legend When Using Time Intelligence Measures | PeryTUS IT Solutions  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hello @parry2k  thank you very much for your effort!
But unfortunately this doesn´t solve my problem completely, because if I sum up the min- and the max values it doesn´t match with the shown total sum 😕 

I tried:

Time Difference = 
VAR __table = ALLEXCEPT ( Table, Table[TrackingCode] ) 
VAR __minTime = CALCULATE ( MIN ( Table[ScanTime] ), __table )
VAR __maxTime = CALCULATE ( MAX ( Table[ScanTime] ), __table )
Var Diff = DATEDIFF ( __maxTime, __minTime, MINUTE )
Return
sumx(values(Table[TrackingCode]),Datediff)

But this shows a much higher Total 😕


Thank you

Stewwe

Ok, now I have it!:

Time Difference = 
Time Difference =
VAR __table =
    ALLEXCEPT ( Table, Table[TrackingCode] )
RETURN
    SUMX (
        VALUES ( Table[TrackingCode] ),
        DATEDIFF (
            CALCULATE ( MAX ( Table[ScanTime] ), __table ),
            CALCULATE ( MIN ( Table[ScanTime] ), __table ),
            MINUTE
        )
    )

 Thank you!

Stewwe

 

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.

Top Kudoed Authors