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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Finding the Sum of Time Duration

I am having trouble creating a measure to sum time duration based on shipment number.

 

I am needing to create a measure to calculate the time duration based on my time data. This will change based on slicers in my report. 

 

I am wanting to use a card to display the total time that a shipment number was available. For example using the data below, shipment no 65 was available from 2:10pm - 4:09pm. If shipment 65 was selected in the slicer, the card would display 1hr 59 mins. 

Account NameShipment NoTime
A545:49:50 PM
X754:19:19 PM
J854:10:51 PM
J654:09:29 PM
C573:52:58 PM
J853:17:52 PM
M413:07:07 PM
J652:16:27 PM
J652:10:29 PM
S122:01:33 PM
X921:49:00 PM

I appreciate any help.

1 ACCEPTED SOLUTION
Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,
If I understand your question, please try this.

 

Length = 

var _shipment = MAX(DurationTable[Shipment No])

var _calcMin = CALCULATE(MIN(DurationTable[Time]), FILTER(ALL(DurationTable), DurationTable[Shipment No]=_shipment))

var _calcMax = CALCULATE(MAX(DurationTable[Time]), FILTER(ALL(DurationTable), DurationTable[Shipment No]=_shipment))

var _duration = DATEDIFF(_calcMin,_calcMax,MINUTE)

var _time = ROUNDDOWN(DIVIDE(_duration,60),0) & " Hour(s) " & MOD(_duration,60) & " Minute(s)"

return IF(MAX(DurationTable[Time])= _calcMax, _time)

Nathaniel_C_0-1688599100661.png



Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Nathaniel_C , 

This worked perfectly! Thank you!

Hi @Anonymous ,
You are very welcome!
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,
If I understand your question, please try this.

 

Length = 

var _shipment = MAX(DurationTable[Shipment No])

var _calcMin = CALCULATE(MIN(DurationTable[Time]), FILTER(ALL(DurationTable), DurationTable[Shipment No]=_shipment))

var _calcMax = CALCULATE(MAX(DurationTable[Time]), FILTER(ALL(DurationTable), DurationTable[Shipment No]=_shipment))

var _duration = DATEDIFF(_calcMin,_calcMax,MINUTE)

var _time = ROUNDDOWN(DIVIDE(_duration,60),0) & " Hour(s) " & MOD(_duration,60) & " Minute(s)"

return IF(MAX(DurationTable[Time])= _calcMax, _time)

Nathaniel_C_0-1688599100661.png



Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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