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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
EmilyM2019
Helper II
Helper II

Excluding School holidays from date count

Hello all,

 

Looking for some advice if possible.

 

I am building a report that is looking at the length of time a specific HR task is taking. In my data set I have the start data and the end date of the task and I need to count the number of days between the 2 dates. Sounds simple, but I have an issue. I need to be counting in School working days. This will exclude weekends, bank holidays and school holidays.

 

I've got a custom function (from tips that I picked up on here) that excludes the weekends, but for the purpose of holding customers and staff to account for excceding agreed timescales this isn't good enough.

 

If anyone has any advice on how to do this I would be very appreciative.

 

Regards,

Emily.

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @EmilyM2019 ,

 

I have created a sample for your reference. 

 

1. We should have a holiday table like that.

Capture.PNG

 

2. Then we can create a date table as below and we can count the days based on [isworking day].

date = 
ADDCOLUMNS (
    CALENDAR ( DATE ( 2020, 01, 01 ), DATE ( 2020, 12, 31 ) ),
    "isworking day", IF ( WEEKDAY ( [Date], 2 ) > 5 || [Date] IN VALUES ( Holiday[date] ), 0, 1 )
)

 

For more details, please check the pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @EmilyM2019 ,

 

I have created a sample for your reference. 

 

1. We should have a holiday table like that.

Capture.PNG

 

2. Then we can create a date table as below and we can count the days based on [isworking day].

date = 
ADDCOLUMNS (
    CALENDAR ( DATE ( 2020, 01, 01 ), DATE ( 2020, 12, 31 ) ),
    "isworking day", IF ( WEEKDAY ( [Date], 2 ) > 5 || [Date] IN VALUES ( Holiday[date] ), 0, 1 )
)

 

For more details, please check the pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Greg_Deckler
Super User
Super User

Use EXCEPT to exclude holidays. https://community.powerbi.com/t5/Quick-Measures-Gallery/Net-Work-Days/td-p/367362


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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
ImkeF
Super User
Super User

Hi @EmilyM2019 

please check out the function I've posted here: https://www.thebiccountant.com/2020/02/20/date-networkdays-function-for-power-query-and-power-bi/ 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors