Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
t_witzgall
Partner - Contributor III
Partner - Contributor III

Reset variables at midnight

Hi,

I have a QlikView application which I reload at 1 a.m. every day. Sometimes it may be necassary to reload it during the day to get new data.

I want to trigger a different code if it is not the first reload on that day - so I need something like that:

11.07.2016

Midnight:   vReloadTimesToday = 0

1st reload at 1 a.m. results in vReloadTimesToday = 1

reload at 3 p.m. results in vReloadTimesToday = 2

12.07.2016

Midnight:   vReloadTimesToday = 0

1st reload at 1 a.m. results in vReloadTimesToday = 1

Is there a way to "reset" the value of the variable at midnight?

Thanks for your input.

Regards

Tamara

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe define your variable in your load script like

LET vReloadTimesPerDay = Rangesum(If(floor(Today(1)) = floor(ReloadTime()), vReloadTimesPerDay,0),1);

(if you need to start with zero, subtract 1:

LET vReloadTimesPerDay = Rangesum(If(floor(Today(1)) = floor(ReloadTime()), vReloadTimesPerDay,0),1)-1;

)

View solution in original post

2 Replies
swuehl
MVP
MVP

Maybe define your variable in your load script like

LET vReloadTimesPerDay = Rangesum(If(floor(Today(1)) = floor(ReloadTime()), vReloadTimesPerDay,0),1);

(if you need to start with zero, subtract 1:

LET vReloadTimesPerDay = Rangesum(If(floor(Today(1)) = floor(ReloadTime()), vReloadTimesPerDay,0),1)-1;

)

t_witzgall
Partner - Contributor III
Partner - Contributor III
Author

Hi Stefan,

first one helped a lot. Thanks!

If I use your seconds statement, QlikView won't count up - result is always rangesum(0,1)-1  = 0

Regards

Tamara