Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
sarithaallot
Contributor III
Contributor III

WeekDay holiday or public holiday flag in script

Hi
Qlik Users,

This is my scenario
If a conference is on a public holiday or on weekend that should be counted as ‘Available on Field’.how can i achieve this in script.i have created weekend flag in master calender by using below script.and now i want to create a flag for getting public holidays on weekdays(mon-fri).

If(WeekDay(Date)='Sat'
,1
, if(WeekDay(Date)='Sun'
,1,
0)
) AS WeekEnd_Flag,


I am attaching my table below.

 

Thanks

6 Replies
DavidM
Partner - Creator II
Partner - Creator II

Hi,

you need to manually identify your public holiday dates. Then if you want to see if they are on your weekdays you can do it like this:

IF ( WeekDay(holidaydate)<5, true, false)

Weekday returns dual value (text and numeric), values 5,6 are saturday and sundays (unless you other in FirstWeekDay variable in Main)

StarinieriG
Partner - Specialist
Partner - Specialist

Hi,

 

you could try in this way:

 

Add a variable:

SET Holidays = 'holiday1', 'holiday2';

 

Then the flag will be:

If(Match(WeekDay(Date),'Sat','Sun')>0 or Match(Date(Date), $(Holidays))>0,1,0) as WeekEnd_Flag;

 

sarithaallot
Contributor III
Contributor III
Author

If(Match(WeekDay(Date),'Sat','Sun')>0 or Match(Date(Date), $(Holidays))>0,1,0) as WeekEnd_Flag;

is this flag gives weekday holidays and weekend holidays?

StarinieriG
Partner - Specialist
Partner - Specialist

Yes, but before you have to set Holidays manually inside the variable

sarithaallot
Contributor III
Contributor III
Author

can u guide me how to set variable ?

StarinieriG
Partner - Specialist
Partner - Specialist

You have to add this line in the script before the load:

SET Holidays = 'holiday1', 'holiday2', 'holiday3';

instead of holiday1/holiday2/holiday3/ect you have to write holiday dates.