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

Execute script tab during specific period only

Hi,

I have a Qlikview Extract with 3 tabs of code. The extract runs daily. One of the tabs only needs to be executed during specific intervals - say, the months of January and July each year.

At present, it's a case of manually uncommenting the code at the beginning of each period, and then commenting it out again at the end of the period.

This is obviously not a huge hassle, but we may produce more date-dependent script tabs for other dashboards in the future, so I was wondering if this could be automated.

 

Can an IF statement be added to the top of the script tab saying If the current date has the month of Jan or July, then run the code, else skip this tab?

If necessary, I could move this tab so it is the last in the QVW, so rather than 'skipping' a tab, I could put the IF statement in the preceding tab, and add an Exit Script - i.e. If current month is not Jan or July, then exit script, else continue.

Or... if this cannot be added in the script tab itself, perhaps I could make each script tab into a subroutine, and then have an extra tab at the beginning that checks the system date and only calls the SUBs that fit the date criteria?

 

Thanks,

G

Labels (3)
1 Solution

Accepted Solutions
pradosh_thakur
Master II
Master II

if month(today()) ='Jan' or month(today()) ='Jul' THEN

yOUR CODE


END IF

https://help.qlik.com/en-US/qlikview/November2018/Subsystems/Client/Content/QV_QlikView/Scripting/Sc...

Learning never stops.

View solution in original post

4 Replies
MindaugasBacius
Partner - Specialist III
Partner - Specialist III

You're on the right path. IF...ELSE will work perfectly.
I am actually using the same method only I have a 4 hour cyclical reload but one of the tabs need to reload only once a day.

I have the last tab with this script:
IF Date(filetime('C:\5.Data\Extract\Daily.qvd')) > Today() THEN
EXIT Script;
ELSE
...
ENDIF
pradosh_thakur
Master II
Master II

if month(today()) ='Jan' or month(today()) ='Jul' THEN

yOUR CODE


END IF

https://help.qlik.com/en-US/qlikview/November2018/Subsystems/Client/Content/QV_QlikView/Scripting/Sc...

Learning never stops.
gramqlik
Contributor III
Contributor III
Author

Perfect, thanks. Easy as that, eh? Smiley Happy

 

Ok, bonus questions - say I have an Extract QVW that runs hourly and has 3 tabs of code. If I wanted one of the code tabs to only run once a day, say on its 11am execution, could I do something similar but using a time query? Something like:

IF Time(Now(1)) >=11:00:00 AND Time(Now(1)) <12:00:00 THEN

~daily code~

END IF

 

Also, what would the reverse be? i.e. could I just add a NOT?

IF NOT (Time(Now(1)) >=11:00:00 AND Time(Now(1)) <12:00:00)

?

 

Many thanks.

Of course, I could have two separate QVWs running on different schedules, so this is just out of interest.

pradosh_thakur
Master II
Master II

I guess so and looks like it will work unless any scripting error is there. One thing to note your qvw running schedule must fall between that time else the condition won't be true. For example , if it is a dependent task and somehow it gets executed after 12:00:00 it may not run the desired code. Just be careful with that ..


Anyways happy that you got your code working . Please close this thread unless you have something else you need help with.

Thanks
Pradosh
Learning never stops.