Forum Discussion
Date: weekends and holidays
Create a field WorkdayFlag that is 1 when the date in question is a working day (not weekend and not holiday, might be useful to maintain separate WeekendFlag and HolidayFlag fields). Then you can just use
WorkDays = SUM( DimDate[WorkdayFlag] )
- SabineOussi10 years ago
Skilled Sharer
The thing is I need to check every day within the (start date - end date) interval and remove the weekends and holidays, if any.
How can I do that?- greggyb10 years ago
Resident Rockstar
You don't need to check those conditions if you have a field as I described. The SUM() measure will automatically respect any filters you apply, so you'll get the count of working days. You can apply a filter with a slicer, a visualization cross-filter, or one of a visual-, page-, or report-level filter.
Your holidays must come from some source table because there are no built in functions that know when your organization has holidays. A weekday check is simple, just check for
// Power Query WeekdayFlag = let Weekday = Date.DayOfWeek( [Date] ) ,WeekdayFlag = if Weekday > 0 and Weekday < 6 then 1 else 0 in WeekdayFlag // DAX WeekdayFlag = ( WEEKDAY( DimDate[Date] ) > 1 && WEEKDAY( DimDate[Date] ) < 7 ) * 1Your WorkdayFlag would be as follows:
// Power Query WorkdayFlag = if [WeekdayFlag] = 1 and [HolidayFlag] = 0 then 1 else 0 // DAX WorkdayFlag = IF( DimDate[WeekdayFlag] = 1 && DimDate[HolidayFlag] = 0 ,1 ,0 )Then your count of working days measure is just:
WorkingDays = SUM( DimDate[WorkdayFlag] )
Measures automatically respect filter context.
- SabineOussi10 years ago
Skilled Sharer
Thanks greggyb,
Your input was much valuable to make me understand what you previously mentioned.
However, I can't see where I can put my closing date so that it takes the days in between.
As I said before, I only have a start date and an end date and I need to check the days in between whether they were working days or not.
Thanks again,Sabine O.