Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
markp201
Creator III
Creator III

Generic holiday mapping

!So, checking out the various holiday discussions, I noticed that holidays are nothing

more than a date pattern.  For example, christmas is always the 25th so will always be one of the following

Mon Dec25,Christmas

Tue Dec25,Christmas

Wed Dec25,Christmas

Tbu Dec25,Christmas

Fri Dec25,Christmas

Mon Dec26,Christmas

Mon Dec27,Christmas

Note : last two are when the holiday falls on the weekend

Floating holidays have a slightly different pattern.  In the US, memorial day is the last Monday in May

or put another way, memorial day occurs during the the last 7 days of May which means its one of the following

Mon May25,Memorial Day

Mon May26,Memorial Day

Mon May27,Memorial Day

Mon May28,Memorial Day

Mon May29,Memorial Day

Mon May30,Memorial Day

Mon May31,Memorial Day

There's no need to check the year because the pattern is independent of the year

When I create my master calendar, I simply use this mapping table for the six US holidays

MAPPING_TO_HOLIDAY:

MAPPING LOAD * INLINE [

DatePattern,Holiday

Mon Jan1,New Years

Tue Jan1,New Years

Wed Jan1,New Years

Tbu Jan1,New Years

Fri Jan1,New Years

Mon Jan2,New Years

Mon Jan3,New Years

Mon May25,Memorial Day

Mon May26,Memorial Day

Mon May27,Memorial Day

Mon May28,Memorial Day

Mon May29,Memorial Day

Mon May30,Memorial Day

Mon May31,Memorial Day

Mon Jul4,Independence Day

Tue Jul4,Independence Day

Wed Jul4,Independence Day

Tbu Jul4,Independence Day

Fri Jul4,Independence Day

Mon Jul5,Independence Day

Mon Jul6,Independence Day

Mon Sep1,Labor Day

Mon Sep2,Labor Day

Mon Sep3,Labor Day

Mon Sep4,Labor Day

Mon Sep5,Labor Day

Mon Sep6,Labor Day

Mon Sep7,Labor Day

Thu Nov22,Thanksgiving

Thu Nov23,Thanksgiving

Thu Nov24,Thanksgiving

Thu Nov25,Thanksgiving

Thu Nov26,Thanksgiving

Thu Nov27,Thanksgiving

Thu Nov28,Thanksgiving

Mon Dec25,Christmas

Tue Dec25,Christmas

Wed Dec25,Christmas

Tbu Dec25,Christmas

Fri Dec25,Christmas

Mon Dec26,Christmas

Mon Dec27,Christmas

]

;

and use the following in the master calendar load

APPLYMAP('MAPPING_TO_HOLIDAY',TEXT(DATE(tempdate,'WWW MMMD')),'N/A') AS Holiday

Note: update from OP.  Need TEXT function because the mapping is string based.

Tried this with most of the US holidays and it works better than expected.

Easter is a bit of a challenge.

Appreciate any comments if I missed something.  Happy Qliking

Attached a sample document based on Michael's post  Calculating Holidays in script

Added feature:

- Observed vs Actual holiday

- Ability to add holidays for other countries

Enjoy

5 Replies
marcus_sommer

The easter sunday could be calculated and various related holidays could then be generated with a simple offset of n-days of it. How it could be calculated and also be implemented (with a mapping too) could you find here: Master Calendar with movable holidays.

- Marcus

markp201
Creator III
Creator III
Author

Still researching but I believe Easter is dependent on Christmas of the previous year. 

Another advantage is setting up observed vs. actual holidays

Mon Jan1,New Years

Tue Jan1,New Years

Wed Jan1,New Years

Thu Jan1,New Years

Fri Jan1,New Years

Sat Jan1,New Years

Sun Jan1,New Years

Mon Jan3,New Years Observed

Mon Jan2,News Years Observed

marcus_sommer

AFAIK it's not (directly) related to christmas else (if I remember correctly) it's the first sunday after the first full moon after the first day of the spring and therefore it changed with each year.

- Marcus

Peter_Cammaert
Partner - Champion III
Partner - Champion III

And even then, there is a difference between the Western Christian calendar (Gregorian calendar) and the Eastern Christian Calendar (Julian calendar) which made Easter in Greece fall this year exactly one week after Easter in most other countries.

marcus_sommer

Yes, Peter is right and there are various differences between the calendars. If you ever need more to this topic take a look here: Non-Gregorian calendars.

- Marcus