Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
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?

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

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

View solution in original post

5 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

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
Author

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

CELAMBARASAN
Partner - Champion
Partner - Champion

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
Author

Thank you,

And if you want to add to an exixting table?

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

CELAMBARASAN
Partner - Champion
Partner - Champion

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