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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
bhmiller89
Helper V
Helper V

Duration Calculation across days

I have a data set that shows Job Report Dates. 

 

I want to calculate basically someone's shift. For the EndofShift I used the Max Job Report Date/Time and then for the BeginningofShift I used the Min Job Report Date/Time. When I do a DateDiff, the data is correct ONLY IF the employee works a shift in the same day. 

 

We have overnight employees who work, let's say 10pm-6am, and the formula will give a value that isn't 8 hours. 

 

Is there a way to remedy this? I'm using a dynamic date slicer to pick individual days to show the Shift Length 

1 ACCEPTED SOLUTION
v-sihou-msft
Microsoft Employee
Microsoft Employee

@bhmiller89

 

You can just have the EndTime subtract StartTime. The result is calculated in days. To get hours, just multiply by 24.

 

24.PNG

 

You can also do it with Power Query. 

 

25.PNG

 

Or you can write an expression like: 

 

=Duration.Hours(Duration.From([EndTime]-[StartTime]))

26.PNG

 

Regards,

View solution in original post

3 REPLIES 3
v-sihou-msft
Microsoft Employee
Microsoft Employee

@bhmiller89

 

You can just have the EndTime subtract StartTime. The result is calculated in days. To get hours, just multiply by 24.

 

24.PNG

 

You can also do it with Power Query. 

 

25.PNG

 

Or you can write an expression like: 

 

=Duration.Hours(Duration.From([EndTime]-[StartTime]))

26.PNG

 

Regards,

With the duration.hours, How do I make it not respond -16 when the hours are 4pm to 12am which should be 8

Greg_Deckler
Super User
Super User

Can you provide some sample data? Specifically, is it a Date/Time column that has the date and the time? What interval are you using for your DATEDIFF?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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