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

Loop over unknown number of tables

Hi guys,

I am stucked with looping in QlikView.

Need to have loop inside another loop and find the right syntax.

Main problem is that I am using SOAP API, but provider allows only max 100 records per call.

Data structure of calls (cannot be modified) 

SOAP calls:

Call1:                    Call2:                         Call3:

ID                         ID, Name                   ID, Surname

1                           1, Mario                      1, Wuntd

2                           2, John                       2, Rough

.                            .                                   .

.                            .                                   .

100                     100, Rob                     100, Hershey

---------------------------------------------------------------------------------------

Call4:                    Call5:                         Call6:

ID                         ID, Name                   ID, Surname

101                       101, Gerd                  101, Herbs

102                       102, Matt                  102, Teckly

.                            .                                   .

.                            .                                   .

200                     200, David                     200, Diaz

-----------------------------------------------------------------------------------------

Call7:                    Call8:                         Call9:

ID                         ID, Name                   ID, Surname

201                       201, Damon                 201, Ypson

202                        202, Martin                 202, Couf

.                            .                                   .

.                            .                                   .

234                     234, Steve                    234, Darms

--------------------------------------------------------------------------------

Call 7, Call 8, Call9 are last tables to be loaded because of no of rows in last load is not 100. Table names are not mandatory.

I need to join tables with same IDs and also keep running load until number of rows in last call is less then 100 (including this table).

Number of tables (vertically) is unknown, we cant say like stop after three iterations.

Thank you for any help.

Best regards,

Martin

ECG line chart is the most important visualization in your life.
1 Solution

Accepted Solutions
marcus_sommer

Maybe something like this is helpful:

let vNumberOfCalls = 100;

for i = 1 to $(vNumberOfCalls)

     let vLoadSatement = pick(mod($(i), 3) + 1,

               't1: Load ID From YourSource',

               't2: Load ID, Name From YourSource',

               't3: Load ID, Surname From YourSource');

     $(vLoadSatement)

next

Match:

load * From t1;

     left join

load * From t2;

     left join

load * From t3;

drop tables t1, t2, t3;

- Marcus

View solution in original post

2 Replies
marcus_sommer

Maybe something like this is helpful:

let vNumberOfCalls = 100;

for i = 1 to $(vNumberOfCalls)

     let vLoadSatement = pick(mod($(i), 3) + 1,

               't1: Load ID From YourSource',

               't2: Load ID, Name From YourSource',

               't3: Load ID, Surname From YourSource');

     $(vLoadSatement)

next

Match:

load * From t1;

     left join

load * From t2;

     left join

load * From t3;

drop tables t1, t2, t3;

- Marcus

mato32188
Specialist
Specialist
Author

Thank you Marcus. It helped a lot!

ECG line chart is the most important visualization in your life.