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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

When summing a list of values only Grab first instance

I have a list of values coming through in a table that is a list of times for a trip.   Like below where Duration is the entire length of the trip in hours

 

Trip  Stop     Start           End             Duration

A       1          8:30 am      9:00am           2.5

A        2          9:10 am      10:00 AM       2.5

A        3           10:10 am     11:00 AM      2.5

 

I need to use the Duration in other calculations.  Like if stop 1 is a certain percentage of the duration.

 

How can I only pull any of those duration instances in my calculation?  I don't want to sum them since that would be duplicating things.

Does this make sense?  Below is my attempt at this... this only sums by Trip Number so it duplicates.  

SUMX(Distinct(FactAnalytics[TripNumber]),CALCULATE(SUM(FactAnalytics[Duration]))
)
1 ACCEPTED SOLUTION

Hi @Anonymous ,

You want to calculate total duration which should be 37.53 in your sample. Right? If I understand correctly, you could try the following formula.

Total Duration = 
var a = CALCULATETABLE(VALUES('Table'[StopTimeHours]),ALLEXCEPT('Table','Table'[TripNumber],'Table'[Driver]))
return 
SUMX(a,'Table'[StopTimeHours])

7.PNG

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
MFelix
Super User
Super User

Hi @Anonymous ,

 

Looking at you data and being you value always the same you can use one of the below values:

 

 

Duration = MAX(FactAnalytics[Duration])

Duration = MIN(FactAnalytics[Duration])

Duration = AVERAGE(FactAnalytics[Duration])

However if the different lines have different values you need to add an agregator or a filter to get the needed result.

 

Can you share some addtional information about what you want to achieve?

 

Regards,

MFelix

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

@MFelix ,

Thanks for the reply and I would use those but I will need to test a lot to verify it won't mess up.  

 

Basically i have Trip Durations by Utilization percents.  I want to use this as part of a calculation to to say things such as for Driver A his utilization was x %.  So I would say Driver A has a max duration (fixed amount) i would use this to calculate how well they are utilized.

 

 

Hi @Anonymous ,

 

Based on context (and this can be a different number of things) using one of the options I have refered should work however the information you have is very reduced so difficult to give you a better answer.

 

Can you share some more information or insights? 

 

Please see this post regarding How to Get Your Question Answered Quickly:

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490 (courtesy of @Greg_Deckler).

 

Regards,

MFelix

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Thanks @MFelix ,

I was preparing some sample data.  Please let me know how this looks.  I want to be able to sum up the hours by trip so they can be viewed at a month/day level but also by Driver and such.

 

So the max/min/average doesn't work.  Since it will grab the average of all the Durations at the Month level.  I would want it to sum each individual trip duration for the time period selected.  

 

StopNumberTripNumberDriverRouteStartRouteEndStopTimeHours   
1aa1/1/18 1:00 PM1/2/18 4:42 PM27.7   
2aa1/1/18 1:00 PM1/2/18 4:42 PM27.7   
3aa1/1/18 1:00 PM1/2/18 4:42 PM27.7   
4aa1/1/18 1:00 PM1/2/18 4:42 PM27.7 Work Hours40
5aa1/1/18 1:00 PM1/2/18 4:42 PM27.7 Total Duration37.53
6aa1/1/18 1:00 PM1/2/18 4:42 PM27.7 Utilized %93.83%
7aa1/1/18 1:00 PM1/2/18 4:42 PM27.7   
8aa1/1/18 1:00 PM1/2/18 4:42 PM27.7   
9aa1/1/18 1:00 PM1/2/18 4:42 PM27.7   
10aa1/1/18 1:00 PM1/2/18 4:42 PM27.7   
1bb1/2/18 2:50 AM1/2/18 12:40 PM9.83   
2bb1/2/18 2:50 AM1/2/18 12:40 PM9.83   
3bb1/2/18 2:50 AM1/2/18 12:40 PM9.83   
4bb1/2/18 2:50 AM1/2/18 12:40 PM9.83   
5bb1/2/18 2:50 AM1/2/18 12:40 PM9.83   
         

Hi @Anonymous ,

You want to calculate total duration which should be 37.53 in your sample. Right? If I understand correctly, you could try the following formula.

Total Duration = 
var a = CALCULATETABLE(VALUES('Table'[StopTimeHours]),ALLEXCEPT('Table','Table'[TripNumber],'Table'[Driver]))
return 
SUMX(a,'Table'[StopTimeHours])

7.PNG

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

So that was working in the table but if I have a dashboard where this is part of one of my calculations it is ignoring all the filters on said dashboard.  So I can't pull up trips by dates or locations.  I see that is how AllExcept works but is there a way around this?

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.