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
Infidti
Frequent Visitor

Hours between 2 dates excluding non working hours/weekends/

Hi there, 

 

I am trying to find a simple way to calculate the hours difference between two dates. But I need to exclude bank holidays and weekends but also the calculation can only sum the hours in-between specified working hours. If something comes through outside of these working hours the sum would only start the next day at the working hour start time. I have seen loads of diff calculations but none seem to work the way I want. I have managed to a calculation to work but doesn't take into account stuff that comes outside working hours. Any help would be amazing

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Infidti ,

Here are the steps you can follow:

1. Enter data -- create calculated table.

Create a table to hold the dates of Bank Holidays

vyangliumsft_0-1675415287351.png

2. Set the working hours and multiply the working hours by the number of working days.

TIME(9,0,0) -- TIME(17,0,0)

3. Create measure.

Measure =
var _worktime=
DATEDIFF(
TIME(9,0,0),TIME(17,0,0),HOUR)
var _count=
COUNTX(FILTER(
    ALL('Table'),
    NOT('Table'[Date]) in SELECTCOLUMNS('Holiday',"holiday",[bank holidays]) &&
 NOT( WEEKDAY('Table'[Date],2)) in {6,7}),[Date])
return
_count * _worktime

4. Result:

vyangliumsft_1-1675415287351.png

 

Best Regards,

Liu Yang

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

2 REPLIES 2
Anonymous
Not applicable

Hi  @Infidti ,

Here are the steps you can follow:

1. Enter data -- create calculated table.

Create a table to hold the dates of Bank Holidays

vyangliumsft_0-1675415287351.png

2. Set the working hours and multiply the working hours by the number of working days.

TIME(9,0,0) -- TIME(17,0,0)

3. Create measure.

Measure =
var _worktime=
DATEDIFF(
TIME(9,0,0),TIME(17,0,0),HOUR)
var _count=
COUNTX(FILTER(
    ALL('Table'),
    NOT('Table'[Date]) in SELECTCOLUMNS('Holiday',"holiday",[bank holidays]) &&
 NOT( WEEKDAY('Table'[Date],2)) in {6,7}),[Date])
return
_count * _worktime

4. Result:

vyangliumsft_1-1675415287351.png

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@Infidti , refer if this can help

https://exceleratorbi.com.au/calculating-business-hours-using-dax/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.