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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.