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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
TenguMan
Frequent Visitor

How to limit duration to a given time range

Hello,

 

I have a report that deals with customer service case data and how long a given case takes. I have been asked to calculate the duration of these cases such that it only counts the time that falls within specified business hours (in this case, 8:00 AM to 8:00 PM). A sample table is below:

Case NumberCase OpenedCase ClosedDuration (Hours)
CS00000018:00:00 AM8:00:00 PM12
CS00000028:00:00 AM7:00:00 AM23
CS00000037:00:00 PM7:59:00 AM12.98

 

After this calculation, the table should look like this:

Case NumberCase OpenedCase ClosedDuration (Hours)
CS00000018:00:00 AM8:00:00 PM12
CS00000028:00:00 AM7:00:00 AM12
CS00000037:00:00 PM7:59:00 AM

1

 

How can I go about doing this in Power BI? Any assistance is greatly appreciated. Thank you!

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@TenguMan (3) Net Work Duration (Working Hours) - Microsoft Fabric Community



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
halfglassdarkly
Responsive Resident
Responsive Resident

How are you accounting for cases that span multiple days (assuming that is possible)?

 

If you have a date/time value you can use the DATEDIFF function to calculate hours between date times. E.g.

 

DATEDIFF([Start Date/Time],[End Date/Time],HOUR)

 

If you have Date and Time as seperate columns you can add them together like so:

 

DATEDIFF([Start Date]+[Start Time],[End Date]+[End Time],HOUR)

If you only care about comparing time and not date (if case open/close are always the same date) you could use an arbitrary date e.g.


DATEDIFF(DATE(2024,01,01)+[Start Time],DATE(2024,01,01)+[End Time],HOUR)

 

UPDATE: apologies, I completely missed the part where you said you needed to calculate work hours. Greg's solution looks more promising for that.

 

Greg_Deckler
Community Champion
Community Champion

@TenguMan (3) Net Work Duration (Working Hours) - Microsoft Fabric Community



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

This worked perfectly, thank you!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.