Skip to main content
Announcements
Join us on Sept. 17 to hear how our new GenAI Assistant empowers data professionals: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlikuser225
Contributor III
Contributor III

Load ID’s into variable and pass them to other table one at a time using for loop

Hello All, 

Can you please help me to understand how to Load ID’s into variable from one table and pass them to other table one at a time using for loop

example- 

table 1

iD,  State

1,AAA

2,BBB

Table2:

iD,testID

1,1.1

1,1.2

2,2.1

2,2.2

where iD =( here I want to use variable to pass values of id from table 1 - one at at time using for loop)

 

Thanks in advance 

Labels (3)
3 Replies
Ahidhar
Creator III
Creator III

something like this

table1:
load * inline
[
iD, State

1,AAA

2,BBB
];


for each i in FieldValueList('iD')
Table2:
let vvar=i;
load
'$(vvar)' as iD
AutoGenerate 1;
next i;

Gabbar
Specialist
Specialist

Try this:-

For i = 1 to NoOfRows('Table1')
Let vField = Peek('ID',i-1,'Table1');
//////////// Check These Variable Using Trace ////////////////
Table2:
Load * From Source where ID = '$(vField)';
Next;

/////////////// Depends on you if you want to concatenate or not.

Vegar
MVP
MVP

@Qlikuser225 you have received two different suggestions to solve this. Please accept them if they solve your problem. 

If thay are not the solution you need. Can you be more specific on why you need the loop and what will you do with the loop? Depending on your goal the two different suggestions can have different strengths,  and maybe you are actually better of with a solution that is not  using a loop.