Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

sudhakaran_abha
Contributor

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

Re: Assigning dynamic table name in For Loop

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

3 Replies

Re: Assigning dynamic table name in For Loop

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

Re: Assigning dynamic table name in For Loop

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

sudhakaran_abha
Contributor

Re: Assigning dynamic table name in For Loop

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.

Community Browser