Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sathish_kumar
Contributor II
Contributor II

While/For loop in qlikview to repeat rows

Hello Team,

I am trying to repeat Rows in qlikview based on the below screenshot. Each row should be repeated based on the difference between From and To Date as shown in expected output screenshot.

I have also attached qlikview file where i attempted using WHILE ITERATION but i am not getting through.

Can you please check and correct the issue in that qlikview file

INPUT

Input.JPG

Expected OUTPUT

Output.JPG

stalwar1

1 Solution

Accepted Solutions
haribabugv
Creator
Creator

Can you try something like while loop

New:

Directory;

LOAD From, To,Product,Sales%

FROM

From_To.xlsx

(ooxml, embedded labels, table is Input);

NoConcatenate

New_1:

load Product,Sales%, Date(From + IterNo()) as Date

resident  New

WHILE  From + IterNo() -1<= To;

Drop table New;

View solution in original post

5 Replies
dplr-rn
Partner - Master III
Partner - Master III

Use this in your script. highlighted the changed parts

New_1:

LOAD

Date(From+IterNo()) as Date, //not sure why you were adding months basing this on your desired output

Product,

Sales%

While From + IterNo() <= To;

Load *

Resident New;

output

Date Product Sales%
19-10-2018A0.1
20-10-2018A0.1
21-10-2018A0.1
22-10-2018A0.1
23-10-2018A0.1
24-10-2018A0.1
25-10-2018A0.1
19-10-2018B0.2
20-10-2018B0.2
21-10-2018B0.2
22-10-2018B0.2
23-10-2018B0.2
24-10-2018B0.2
25-10-2018B0.2
26-10-2018B0.2
27-10-2018B0.2
28-10-2018B0.2
29-10-2018B0.2
30-10-2018B0.2
31-10-2018B0.2
01-11-2018B0.2
19-10-2018C-0.1
20-10-2018C-0.1
21-10-2018C-0.1
22-10-2018C-0.1
23-10-2018C-0.1
24-10-2018C-0.1
25-10-2018C-0.1
26-10-2018C-0.1
27-10-2018C-0.1
28-10-2018C-0.1
29-10-2018C-0.1
30-10-2018C-0.1
31-10-2018C-0.1
01-11-2018C-0.1
02-11-2018C-0.1
03-11-2018C-0.1
04-11-2018C-0.1
05-11-2018C-0.1
lironbaram
Partner - Master III
Partner - Master III

hi

use this script :

New:

LOAD From, To,

      date(From +IterNo()-1) as Date, 

     Product,

     Sales%

FROM

From_To.xlsx

(ooxml, embedded labels, table is Input)

while From+IterNo()-1<=To;

haribabugv
Creator
Creator

Can you try something like while loop

New:

Directory;

LOAD From, To,Product,Sales%

FROM

From_To.xlsx

(ooxml, embedded labels, table is Input);

NoConcatenate

New_1:

load Product,Sales%, Date(From + IterNo()) as Date

resident  New

WHILE  From + IterNo() -1<= To;

Drop table New;

sunilkumarqv
Specialist II
Specialist II

LOAD From,

Date( From + IterNo()-1) as Date,

     To,

     Product,

     Sales%

FROM

[..\Desktop\From_To.xlsx]

(ooxml, embedded labels, table is Input)  While IterNo() <= To - From + 1 ;Output.PNG