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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Albatross810
Regular Visitor

NETWORKDAYS dynamically filtering by dates and person

I want to calculate the working days between dates with varying holidays within a specified period. For example, I have a table that lists personal holidays:

 

PersonHolidays
Jane02-Feb-23
Jane03-Mar-23
Jane21-Jul-23
Michael01-Mar-23

 

And I have a table with jobs

                                          Jobs
JobPersonStartEndAvailability
Job 1Jane01-Jan04-Feb(Working days - holidays)
Job 2Michael10-Feb21-Apr 

 

I need the Availability column to include working days between those dates (or dates i select from a slicer, for example all of February), removing dates from the other table where the person has a holiday. Can anyone help me find a solution for this please?

1 ACCEPTED SOLUTION

@Albatross810 So like this?

Measure = 
    VAR __Person = MAX('Jobs'[Person])
    VAR __Result = NETWORKDAYS(MAX([Start]), MAX([End]), 1, SELECTCOLUMNS(FILTER('Holidays', [Person] = __Person),"__Holidays",[Holidays]))
RETURN
    __Result

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

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@Albatross810 New way: NETWORKDAYS function (DAX) - DAX | Microsoft Learn

Old way: Net Work Days - Microsoft Power BI 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Been working with NETWORKDAYS all day, can't seem to solve this one. It doesn't sum multiple periods if I'm selecting several for example and won't let me use the holiday table dynamically by owner. But thank you for sharing.

@Albatross810 So like this?

Measure = 
    VAR __Person = MAX('Jobs'[Person])
    VAR __Result = NETWORKDAYS(MAX([Start]), MAX([End]), 1, SELECTCOLUMNS(FILTER('Holidays', [Person] = __Person),"__Holidays",[Holidays]))
RETURN
    __Result

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

Thanks so much, this worked well!

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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