Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

sarithaallot
New 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
Partner
Partner

Re: WeekDay holiday or public holiday flag in script

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)

Partner
Partner

Re: WeekDay holiday or public holiday flag in script

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
New Contributor III

Re: WeekDay holiday or public holiday flag in script

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?

Partner
Partner

Re: WeekDay holiday or public holiday flag in script

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

sarithaallot
New Contributor III

Re: WeekDay holiday or public holiday flag in script

can u guide me how to set variable ?

Partner
Partner

Re: WeekDay holiday or public holiday flag in script

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.