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

Help on Generic Load

HI ALl,

I have seen so many posts on Generic Load.

After writting Generic load statement (

Table2:

generic load *

resident Table1

)

i see the below code

ResultTable:

LOAD Distinct ID, name Resident Table1;

FOR i = 0 to NoOfTables()

  TableList:

  LOAD TableName($(i)) as Tablename AUTOGENERATE 1

  WHERE WildMatch(TableName($(i)), 'Table2.*');

NEXT i

FOR i = 1 to FieldValueCount('Tablename')

  LET vTable = FieldValue('Tablename', $(i));

  LEFT JOIN (ResultTable) LOAD * RESIDENT [$(vTable)];

  DROP TABLE [$(vTable)];

NEXT i

Drop Tables Table1, TableList

Can anyone please make me understand the above code step by step what it is actually doing?  Is above mentioned code is common one?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

The code you have provided has the following descriptions:

Step 1)  It loads distinct id and name from Table1

Step 2)  Then with the help of 'for loop'  it loads only that tablename which starts with 'Table2.' in the field 'Tablename'.

Step 3)  With the help of next for loop, it loads all the contents from the tables iteratively, table name are retrieved from the variable 'vTable'  which will loop till the last value of the field 'Tablename' and then  the corresponding contents are left join to the table 'ResultTable' and then tables are dropped (since their contents are saved into another table named ResultTable)

Step 4)  Then it drop the tables (Table1,TableList) to avoid the generation of  synthetic keys.

and to know the concept of Generic Load you can refer the following thread

http://community.qlik.com/thread/66833

Thanks and Regards,

Geeta

View solution in original post

2 Replies
MarcoWedel

Generic loads generate multiple tables associated by at least one common field.

The code fragement you posted recombines those tables into one and drops the corresponding source tables, i.e. it generates one table that includes all fields generated by the generic load.

For pros and cons see also:

http://community.qlik.com/blogs/qlikviewdesignblog/2014/03/31/generic

by Henric Cronström

Use cases for Generic Load | Qlikview Cookbook

by Rob Wunderlich

hope this helps

regards

Marco

Anonymous
Not applicable
Author

Hi,

The code you have provided has the following descriptions:

Step 1)  It loads distinct id and name from Table1

Step 2)  Then with the help of 'for loop'  it loads only that tablename which starts with 'Table2.' in the field 'Tablename'.

Step 3)  With the help of next for loop, it loads all the contents from the tables iteratively, table name are retrieved from the variable 'vTable'  which will loop till the last value of the field 'Tablename' and then  the corresponding contents are left join to the table 'ResultTable' and then tables are dropped (since their contents are saved into another table named ResultTable)

Step 4)  Then it drop the tables (Table1,TableList) to avoid the generation of  synthetic keys.

and to know the concept of Generic Load you can refer the following thread

http://community.qlik.com/thread/66833

Thanks and Regards,

Geeta