QlikSense: reload only during business hours - a 'quick and dirty' setup/workaround
I needed an option of running tasks on 15min-basis and hourly-basis only during business hours. However, it seems that the only option in QlikSense is to set one 'weekly' task for each execution, i.e. 4 tasks for each hour needed to run in the 15-min option and one task per hour for hourly run, for ALL tasks).
Obviously, there had to be a better way around this and I thought about a functional, albeit 'unelegant' manner to quickly and easily configure this. Until Qlik rebuilds this option into Sense QMC (as in QlikVIew) or I become an Engine API expert (always think positive), I think this setup should work.
Create and publish in a private stream an app with the following script:
LET vSOBD = NUM(MakeTime(02,00));
LET vCOB = NUM(MakeTime(21,30));
IF (WeekDay(TODAY()) <> 'Sat' AND WeekDay(TODAY()) <> 'Sun') AND (FRAC(Time(NOW())) >= $(vSOBD) AND FRAC(Time(NOW())) <= $(vCOB)) THEN
LOAD FAIL FROM ERROR;
This script takes one second to reload in both IF and ELSE scenarios. Reading from the script, it might have become obvious what I am trying to do and also why it is 'unelegant'.
The vSOBD and vCOB variables are where you set business start hours and end hours and you can also change the day of run to Weekdays and exclude any specific day, e.g. in this case weekends.
If it is during a business day and hour you have set, it will 'exit script'. If it isn't a business day and hour, it will fail. This is the 'unelegant' part, as I hate to see 'red' X on my QMC Tasks.
However, you can quickly create tasks, which reloads every X hours or X mins and then attach all proper reloads on the 'successful completion' of the respective X-hours or X-mins task.
Hope this helps whilst waiting for a true solution.