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: 
prayner
Contributor III
Contributor III

List values from a year range in for loop

My table is too big for one Qlik Sense dashboard to run in our production environment, therefore it needs to be split into QVD files for every two year period between 2002 and Year(Today()).

To achieve this, I am running a `for each` loop that would feed every other year value in this range into:

- a WHERE clause of the SQL query filtering by datetime (ISO8601).

- the STORE file path.

LET $(vYearList) = 2002:Year(Today();

for Each Year in $(vYearList)

LOAD STATEMENT;
SQL QUERY
WHERE datetime > ($(Year)-2)-01-01 and datetime < $(Year)-12-31
FROM DB;

Store TABLE into [lib://PATH_$(Year)_($(Year)-2).qvd](qvd);

 It would take a while to setup the reprex, but any advice on how you would write this script is appreciated, even if it's just for every year.

Labels (1)
1 Reply
marcus_sommer

I think I would slice the data yearly - maybe with:

for i = 2002 to year(today())
   ... // and $(i) is then your year-variable within the where clause and by the storing
next