# 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