
Creator
2020-01-02
04:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
do while with if statement
Hi Guys,
I have a problem with do while and an if statement.
I want to load Data from 5 Years ago to today, but on 01.01. the Data should be load from 5 years ago to year(today)-1, because on 01.01. I haven't Data from the actual year.
Example:
LET a=year(today())-5;
if num(month(Today()))=01 and day(today())=01 then
do while a<=year(today())-1;
ELSE
do while a<=year(today());
TEST:
Load
*
from TEST_(a).csv;
LET a=a+1;
Loop
ENDIF;
How can I do this????
Regards Chris
- Tags:
- qlikview_scripting
840 Views
1 Solution
Accepted Solutions

Master II
2020-01-02
06:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe like this:
if num(month(Today()))=1 and num(day(today()))=1 then
For a = year(today())-5 to year(today())-1;
TEST$(a):
Load
*, FileName() as Filename
FROM
[Test_$(a).csv];
next a;
ELSE
For b = year(today())-5 to year(today())
TEST$(b):
Load
*, FileName() as Filename
FROM
[Test_$(b).csv];
next b;
endif;
810 Views
3 Replies

Master II
2020-01-02
06:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe like this:
if num(month(Today()))=1 and num(day(today()))=1 then
For a = year(today())-5 to year(today())-1;
TEST$(a):
Load
*, FileName() as Filename
FROM
[Test_$(a).csv];
next a;
ELSE
For b = year(today())-5 to year(today())
TEST$(b):
Load
*, FileName() as Filename
FROM
[Test_$(b).csv];
next b;
endif;
811 Views

Creator
2020-01-02
07:06 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Frank,
thanks for your quick answer.
Yes this works!
Have a nice day!
Chris
801 Views

Master II
2020-01-02
07:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if you want to do it with a do while clause then also try this:
LET a=year(today())-5;
if num(month(Today()))=1 and num(day(today()))=1 then
do while a<=year(today())-1;
TEST:
Load
*,FileName() as Filename
From
[C:\Users\admin\Desktop\Neuer Ordner (5)\Test_$(a).xlsx]
(ooxml, embedded labels, table is Tabelle1);
Let a=$(a)+1;
loop;
ELSE
do while a<=year(today());
TEST:
Load
*,FileName() as Filename
From
[C:\Users\admin\Desktop\Neuer Ordner (5)\Test_$(a).xlsx]
(ooxml, embedded labels, table is Tabelle1);
Let a=$(a)+1;
Loop
ENDIF;
794 Views
