Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
My_Rebecca
Creator
Creator

Variable for Public Holiday

NetWorkDays are used to calculate the working date, but there are too much dates in recent 2 years.

For example, '2021-10-01','2021-10-02','2021-10-03','2021-10-04','2021-10-05','2021-10-06','2021-10-07','2021-12-24','2021-12-25','2022-01-01','2022-01-02','2021-01-03'......

Everytime I write the expression, I have to copy that long. It's not convenient. 

Is it possible to create holiday variable containing all of these dates and add new holiday dates freely?

Labels (1)
5 Replies
sandeep-singh
Creator II
Creator II

Hi @My_Rebecca, Yes, you can all these dates in the variable. 

Try this

Inline_Holidays:
LOAD * INLINE [
PublicHolidays
'2021-10-01'
'2021-10-02'
'2021-10-03'
'2021-10-04'
'2021-10-05'
'2021-10-06'
'2021-10-07'
'2021-12-24'
'2021-12-25'
'2022-01-01'
'2022-01-02'
'2021-01-03'
];

TempHoliday:
Load
Concat(PublicHolidays,',') as Pub_Holidays
Resident Inline_Holidays;

Let vHolidays = Peek('Pub_Holidays');
Trace '$(vHolidays)'


Drop table Inline_Holidays, TempHoliday;

Now you can use vHolidays variable in your expression.
NetWorkDays(StartDate,EndDate, $(vHolidays))

My_Rebecca
Creator
Creator
Author

Dear @sandeep-singh , could this variable be used in all sections in one app?

My_Rebecca_0-1682067022799.png

 

sandeep-singh
Creator II
Creator II

Hi @My_Rebecca, Yes, you can use in all sections in one app. 

My_Rebecca
Creator
Creator
Author

Dear @sandeep-singh , it seems that this variable is not created successfully, the calculation is not right.

NetWorkDays([DN Creation Date],[Post Goods Issue Date],'$(vHolidays)')

My_Rebecca_0-1682230190553.png

My_Rebecca_1-1682230337872.png

 

sandeep-singh
Creator II
Creator II

hi @My_Rebecca, I checked the script and it seems to be working fine. I believe you have to make a small adjustment or formatting of dates in your script. Could you please help me with your script so that I can update it accordingly.