
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For each loop with a variable
Hi,
i have data:
Table:
Equ,
Class
I need to use For each loop based on Equ values, but inside the loop I need to create a variable with corresponding Class value - how to do that?
For each i in FieldValueList ('Table')
let vClass = ???
load final table..
next i
Appreciate your help
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could solve this by creating an mapping table from equ to class.
Table: Load Ecu, Class From Source;
MapClass: Mapping Load Ecu, Class Resident Table;
For each i in FieldValueList ('Ecu') //FieldValueList takes field name as parameter, not table name
let vClass = applymap('MapClass', '$(i)', 'Not mapped');
load final table..
next i
Qlik Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, you can add the value as:
For each vClass in FieldValueList ('Class')
LET vClass = '$(i)';
But note that this variable will be overwritten with each iteration of the for each bucle. Is this what you want?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could solve this by creating an mapping table from equ to class.
Table: Load Ecu, Class From Source;
MapClass: Mapping Load Ecu, Class Resident Table;
For each i in FieldValueList ('Ecu') //FieldValueList takes field name as parameter, not table name
let vClass = applymap('MapClass', '$(i)', 'Not mapped');
load final table..
next i
Qlik Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, no this is not what I mean. Because for each Equ I need to take the exact class that is assigned to Equ.
So having data:
Table:
Equ Class
1 A
2 B
3 A
4 C
I need a loop
For each i in fieldvaluelist('Equ') e.g. 1
load some data
where Class = A,
for i=2...
load
where Class = B
...
