Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Assigning dynamic table name in For Loop

Hi,

Is it possible to assign dynamic tables based on changing numeric values in the for loop ?

Please refer to the sample code below:

For i = 1 to 12

TableName & $(i):

LOAD *

RESIDENT

Next i;

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hi Sudhakaran,

Yes. We can assign dynamic table names. Check the below script.

For i = 1 to 4

Qualify '*';

[TableName $(i)]:

Load

  AddMonths(today(),12) - recno() AS Date

Autogenerate (AddMonths(today(),12) - MakeDate(2016,01,01));

Next i;

Capture.PNG

View solution in original post

3 Replies
tamilarasu
Champion
Champion

Hi Sudhakaran,

Yes. We can assign dynamic table names. Check the below script.

For i = 1 to 4

Qualify '*';

[TableName $(i)]:

Load

  AddMonths(today(),12) - recno() AS Date

Autogenerate (AddMonths(today(),12) - MakeDate(2016,01,01));

Next i;

Capture.PNG

Kushal_Chawda

what do you mean by assigning dynamic table name? what is requirement? why you want to do that?

Anonymous
Not applicable
Author

Hi Kushal,

There are multiple reasons why this approach is needed:

1. To load separate monthly tables, and load them into separate QVDs

2. Avoid the recursive load of all data to be concatenated into a single table.

2. Process data for different months differently (this is where it is easier when we have different table names for each month)

Hope this helps.