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
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
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.