 # Holidays and weekends

Please help me with this formula. I know I need to create a table containing my holidays and link the table to my date table. How do I write the dax formula to put a 0 in all weekends and holidays?

Yes, I am embarrassed to even show you my work around. WorkingDays =
IF (
OR ( DateDimension[DayOfWeek] = 7, DateDimension[DayOfWeek] = 1 ),
0,
IF (
DateDimension[Date] = VALUE ( “01/01/2018” ),
0,
IF (
DateDimension[Date] = VALUE ( “01/02/2018” ),
0,
IF (
DateDimension[Date] = VALUE ( “03/30/2018” ),
0,
IF (
DateDimension[Date] = VALUE ( “05/28/2018” ),
0,
IF (
DateDimension[Date] = VALUE ( “07/04/2018” ),
0,
IF (
DateDimension[Date] = VALUE ( “09/03/2018” ),
0,
IF (
DateDimension[Date] = VALUE ( “11/22/2018” ),
0,
IF (
DateDimension[Date] = VALUE ( “11/23/2018” ),
0,
IF (
DateDimension[Date] = VALUE ( “12/25/2018” ),
0,
IF (
DateDimension[Date] = VALUE ( “12/26/2018” ),
0,
IF (
DateDimension[Date] = VALUE ( “01/02/2017” ),
0,
IF (
DateDimension[Date] = VALUE ( “04/14/2017” ),
0,
IF (
DateDimension[Date] = VALUE ( “05/29/2017” ),
0,
IF (
DateDimension[Date] = VALUE ( “07/04/2017” ),
0,
IF (
DateDimension[Date] = VALUE ( “09/04/2017” ),
0,
IF (
DateDimension[Date] = VALUE ( “11/23/2017” ),
0,
IF (
DateDimension[Date] = VALUE ( “11/24/2017” ),
0,
IF (
DateDimension[Date] = VALUE ( “12/25/2017” ),
0,
IF (
DateDimension[Date] = VALUE ( “12/26/2017” ),
0,
IF ( DateDimension[Date] = VALUE ( “12/31/2017” ), 0, 1 )
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)

Wow, I don’t think you should do it this way.

First i really think you should have a separate table is excel or somewhere similar that you can update very easily with the holiday dates.

Then you would have this as a stand alone table. You could then use a LOOKUPVALUE function in a new column within your date table, that looks at the current date and then looks up whether it’s in the holiday table.

Once you have this column it’s a simple IF function.

You can go something like this.

`IF( AND( Weekdays = Saturday, Weekday = Sunday, IsHoliday = TRUE ), 0, 1 )`

This is the logic you need to step through.

Hopefully that makes sense. See how you go with this.

I really don’t like the use of the formula there with all the dates. There’s to much up keep and not enough continuity in my opinion compared to keeping a simple table that just records all the future holiday dates.

1 Like

I knew there was a better way to do this.

`_IF( AND( Weekdays = Saturday, Weekday = Sunday, IsHoliday = TRUE ), 0, 1 )_`

I guess “AND” only allows two arguments. I switched it to “or” by using ||

I usually create a new column by using

``````Weekend - Weekday =

SWITCH (

TRUE (),

Dates[DayInWeek] = 0, "Weekend",

Dates[DayInWeek] = 1, "Weekday",

Dates[DayInWeek] = 2, "Weekday",

Dates[DayInWeek] = 3, "Weekday",

Dates[DayInWeek] = 4, "Weekday",

Dates[DayInWeek] = 5, "Weekday",

Dates[DayInWeek] = 6, "Weekend",

BLANK ()

)
`````` 2 Likes

I did this based on what Sam suggested. I linked to a excel sheet which has only one column, my holiday dates. I added a new column to my date table called “Holiday”. Then I created my final column called “Workday”. Getting holidays to show as 0 was my main goal.

Workday =
IF(DateDimension[DayOfWeek] = 7 || DateDimension[DayOfWeek] = 1 || DateDimension[Holiday] >0,0,1)

Holiday =
LOOKUPVALUE(Holidays[Holiday Dates], Holidays[Holiday Dates], DateDimension[Date])

1 Like

That work just fine also.

Like Sam always says there are many ways to get to the same result.

Was just my humble 2 cents. 1 Like

Nice one. Looks good