Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for 
Search instead for 
Did you mean: 
justinasp
Creator
Creator

using loop FOR EACH ... NEXT

Hello all,

I need to join tables from active tables list. Please see the code below:

Table1=1;
Table2=1;
Table3=0;
IF Table1=1 THEN
NOCONCATENATE
TABLE1:
LOAD * INLINE
[
VAR1, VAR2, VAR3
A, 1, X
B, 2, X
];
ENDIF
IF Table2=1 THEN
NOCONCATENATE
TABLE2:
LOAD * INLINE
[
VAR1, VAR2, VAR4
C, 3, Y
D, 2, Z
];
ENDIF
IF Table3=1 THEN
NOCONCATENATE
TABLE3:
LOAD * INLINE
[
VAR1, VAR2, VAR3
E, 1, 0
F, 4, X
];
ENDIF
InTable:
LOAD IF(TableName=1,TableID) as Table
INLINE
[
TableName, TableID

$(Table1), TABLE1
$(Table2), TABLE2
$(Table3), TABLE3
];
FOR EACH vTable IN {"Need to take $(Table) from InTable"}
ActiveList:
LOAD VAR1,
VAR2
RESIDENT $(vTable);
DROP TABLE $(vTable);
NEXT vTable;


Thank's for any reply,

Justinas

1 Solution

Accepted Solutions
rwunderlich

I'm not understanding exactly what you are rying to accomplish, biut a suggeted syntax may be:

FOR i = 0 TO NoOfRows('InTable') - 1
LET vTable = peek('TableID', $(i), 'InTable')

LOAD VAR1,
VAR2
RESIDENT $(vTable);
DROP TABLE $(vTable);
NEXT i

-Rob

View solution in original post

4 Replies
Not applicable

Use PEEK(). [Schemas]: LOAD * INLINE [ SCHEMANAME, SCHEMATABLES SIS001, "('SCHEMA001','SCHEMA002')" SIS002, "('SCHEMA001','SCHEMA003')" ]; [t_Schemas]: LOAD recno() as SCHEMACOUNT RESIDENT [Schemas]; let count = 1; let schemaCount = peek('SCHEMACOUNT',-1,[t_Schemas]); drop table [t_Schemas]; do while count
justinasp
Creator
Creator
Author

Hi, Fabio,

I'm not sure if I got your mind or your solution is not, what I am looking for this time.

My issue is to use field value from the Inline table as a variable in a loop.

rwunderlich

I'm not understanding exactly what you are rying to accomplish, biut a suggeted syntax may be:

FOR i = 0 TO NoOfRows('InTable') - 1
LET vTable = peek('TableID', $(i), 'InTable')

LOAD VAR1,
VAR2
RESIDENT $(vTable);
DROP TABLE $(vTable);
NEXT i

-Rob

justinasp
Creator
Creator
Author

It was just a peace of the big view, but you leaded me to the right direction. Thank's for your help, Rob.