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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to sum the results of a duration calculation

I am using Power BI to try and calculate Units Picked Per Hour and in order to do that I need to calculate Hours Worked

 

Each employee has multiple work orders and each work order has a first and a last item scanned. I am using a basic DATEDIFF function (MAX pick time minus MIN pick time) to calculate the time between the first scan and the last scan of each work order to calculate the time the employee was picking.

 

However, when I try to look at the TOTAL of those durations for each worker it gives me the difference between the employees first and last pick and the duration is incorrect. 

 

NameWork IDPick TimeUnits Picked
John Smith1238:15 am2
John Smith1238:16 am2
John Smith1238:19 am2
John Smith1238:22 am2
John Smith4568:45 am5
John Smith4568:50 am5
John Smith4568:55 am5

 

So, I used a DATEDIFF to calculate the duration of work ID 123 and 456 and it returns 7 minutes and 10 minutes respectively. That's great. However, if I calculate the duration for John Smith it gives me the INCORRECT 40 minutes because its taking the MAX time minus the MIN time. 

 

How can I create a function that finds the DATEDIFF for each work assignment and then SUMS them for each individual working?

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous try this measure to calculate the time between min and max

 

Pick Time Duration = 
SUMX ( 
    SUMMARIZE ( 
        PickTime, 
        PickTime[Name], 
        PickTime[Work ID], 
        "@Min", MIN ( [Pick Time] ), 
        "@Max", MAX ( PickTime[Pick Time] ) 
    ), 
    DATEDIFF ( [@Min], [@Max], MINUTE ) 
)


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.

View solution in original post

2 REPLIES 2
parry2k
Super User
Super User

@Anonymous try this measure to calculate the time between min and max

 

Pick Time Duration = 
SUMX ( 
    SUMMARIZE ( 
        PickTime, 
        PickTime[Name], 
        PickTime[Work ID], 
        "@Min", MIN ( [Pick Time] ), 
        "@Max", MAX ( PickTime[Pick Time] ) 
    ), 
    DATEDIFF ( [@Min], [@Max], MINUTE ) 
)


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.

Anonymous
Not applicable

Kudos! Thanks, my friend!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.