Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

How to copy fields from one table to an other table using a for loop?

Hi, I want to copy the values of one table to another table using a for loop?

Tags (5)
1 Solution

Accepted Solutions

Re: How to copy fields from one table to an other table using a for loop?

Hi,

You can very well use this sample

Table1:

LOAD *, SubField(States,',') AS StatesUpdated Inline

[

Cust,States

111, "NY,NJ,CT"

222, "TX,AL"];

LET vTotalRows = NoOfRows('Table1');

FOR i=0 to vTotalRows-1

Test:

LOAD

          Peek(StatesUpdated,$(i),'Table1') AS NewField

AutoGenerate 1;

NEXT

Regards,

Celambarasan

5 Replies

Re: How to copy fields from one table to an other table using a for loop?

Hi,

Can you explain the issue clearly it may be done without using for loop also. I helps us to figure it out for you.

Regards,

Celambarasan

Not applicable

Re: How to copy fields from one table to an other table using a for loop?

Hi, I know you can somehow use a join or concatenate

But for know I want to use a for loop, because  I want to do some other stuff within  the loop.

So lets say I have table A with fields A1, A1

Which I want to copy to table B  with fields B1, B2, B3 so that the values of

B3  becomes A1 for e.g

Thanks

Re: How to copy fields from one table to an other table using a for loop?

Hi,

You can very well use this sample

Table1:

LOAD *, SubField(States,',') AS StatesUpdated Inline

[

Cust,States

111, "NY,NJ,CT"

222, "TX,AL"];

LET vTotalRows = NoOfRows('Table1');

FOR i=0 to vTotalRows-1

Test:

LOAD

          Peek(StatesUpdated,$(i),'Table1') AS NewField

AutoGenerate 1;

NEXT

Regards,

Celambarasan

Not applicable

Re: How to copy fields from one table to an other table using a for loop?

Thank you,

And if you want to add to an exixting table?

Let's say that in your case table Test already existed?

Re: How to copy fields from one table to an other table using a for loop?

Based on which condition you have to add a field to existing one?

Community Browser