Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Doubt about simple for?

Hi

I have to concatenate 3 tables with the same fields.

I could do this in this way.

Table 1

field 1

field 2

....

field n

FROM TABLE 1

Table 2

field 1

field 2

....

field n

FROM TABLE 2

Table 3

field 1

field 2

....

field n

FROM TABLE 3

But i'd like to try to use the for . something like this

for table 1 to table 3

field 1

field 2

....

field n

FROM TABLE 1,2,3

how i do this?

thank you

Labels (1)
2 Replies
sunny_talwar
MVP
MVP

This should work


LET vConcatenate = '';

LET vNoTables = 3;

For i =1 to $(vNoTables)

     LET vTable = 'Table' & $(i);   

    Table:

    $(vConcatenate)

    LOAD yourFields

    FROM $(vTable);

    LET vConcatenate = 'Concatenate';

Next;

Best,

Sunny

maxgro
MVP
MVP

if the tables have the same number and name of fields

Qlik will autoconcatenate

table1: load 1 as a, 2 as b autogenerate 10;

table2: NoConcatenate load 1 as a, 2 as b autogenerate 10;

table3: NoConcatenate load 1 as a, 2 as b autogenerate 10;

for i=1 to 3

  table:   load *, 'new' as newfield resident table$(i);

next;

DROP table table1, table2, table3;

DROP Field newfield;