Forum Discussion
NETWORKDAYS() Holiday question
- 1 year ago
You will need to do it the old school way - a dates table that indicates whether a date is a weekend or not, a calculation that counts/sums up the days within the range that are deemed to be weekdays only and exclude holidays.
NETWORKDAYS (old school) = VAR __COUNTRY = "A" -- can refer to a column VAR __HOLIDAYS = SELECTCOLUMNS ( FILTER ( Holidays, Holidays[Country] = __COUNTRY ), [Holidays] ) VAR __RESULT = CALCULATE ( SUM ( 'Calendar'[Weekend?] ), FILTER ( VALUES ( 'Calendar'[Date] ), 'Calendar'[Date] >= Start_End[Start] && 'Calendar'[Date] <= Start_End[End] && NOT 'Calendar'[Date] IN __HOLIDAYS ) ) RETURN __RESULTPlease see attached sample pbix.
Hi olimilo
The holidays table must contain only one column and you dont really need to filter the holidays by the start and end dates.
Networkdays Measure =
VAR _holidays =
SELECTCOLUMNS ( FILTER ( Holidays, Holidays[Country] = "A" ), [Holidays] )
RETURN
NETWORKDAYS (
SELECTEDVALUE ( Start_End[End] ),
SELECTEDVALUE ( Start_End[End] ),
1,
_holidays
)
Networkdays Column =
VAR _holidays =
SELECTCOLUMNS ( FILTER ( Holidays, Holidays[Country] = "A" ), [Holidays] )
RETURN
NETWORKDAYS (
Start_End[End],
Start_End[End],
1,
_holidays
)
1 means weekends are ommitted and are no included in counting. DAX NETWORKDAYS is inclusive of the start and end dates.
Hi Dan, thanks for the response. This means then that it is not possible to indicate weekends outside of what is available in the KB? We are trying to avoid having to create a calculated calendar per entry in the table which is what we previously did to compute for the TATs.
- danextian1 year agoSuper User
What do you mean by to indicate weekends outside of what is available in the KB? I believe the options to indicate which days are the weekends is pretty comprehensive.
- olimilo1 year agoPost Prodigy
You missed my other question:
Another question is, is there a way to add a custom weekend identifier? According to the KB, there is no weekend identifier for Fri+Sun
- danextian1 year agoSuper User
You will need to do it the old school way - a dates table that indicates whether a date is a weekend or not, a calculation that counts/sums up the days within the range that are deemed to be weekdays only and exclude holidays.
NETWORKDAYS (old school) = VAR __COUNTRY = "A" -- can refer to a column VAR __HOLIDAYS = SELECTCOLUMNS ( FILTER ( Holidays, Holidays[Country] = __COUNTRY ), [Holidays] ) VAR __RESULT = CALCULATE ( SUM ( 'Calendar'[Weekend?] ), FILTER ( VALUES ( 'Calendar'[Date] ), 'Calendar'[Date] >= Start_End[Start] && 'Calendar'[Date] <= Start_End[End] && NOT 'Calendar'[Date] IN __HOLIDAYS ) ) RETURN __RESULTPlease see attached sample pbix.