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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I hope you can help me 🙂
First, I have the following table:
| Trackingcode | Scantime |
| 123456 | 26.11.2020 18:28 |
| 123456 | 27.11.2020 20:15 |
| 123456 | 27.11.2020 01:02 |
| 123456 | 26.11.2020 19:10 |
| 123456 | 25.11.2020 00:00 |
| 987654 | 30.11.2020 07:00 |
| 987654 | 30.11.2020 09:17 |
| 987654 | 30.11.2020 07:05 |
| 987654 | 30.11.2020 11:16 |
| 987654 | 30.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
Solved! Go to 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
@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
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 58 | |
| 45 | |
| 42 | |
| 20 | |
| 18 |