Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I need to loop over the records of a table. Seems to be quite easy: for VAR=0 to NoOfRows('TableName') -1
But this is a problem for me. I need VARto be:
VAR |
---|
1 |
2 |
5 |
7 |
11 |
12 |
Otherwise I get an error. Is it possible to make a loop with a list of values like in the table above? Thanks!
try this:
Values:
LOAD * INLINE [
Values
1
2
5
7
11
12
];
load concat (distinct Values,',') as Valuelist resident Values;
drop table Values;
let values=peek('Valuelist',0,'Values');
for each v in $(values)
trace $(v);
next;
I supposed your list was made of constant values
with variable values, you can read it from a table (in my example List)
and then check if they are also in Data table
List:
load Concat(F3, ',') as F3;
LOAD * INLINE [
F3
1
2
5
];
Data:
LOAD * INLINE [
F1
1
2
3
4
5
6
7
8
9
10
];
LET vList = Peek('F3', 0, 'List');
trace 'vList=' $(vList);
for each v in $(vList)
vF1 = Peek('F1', v-1, 'Data');
if ($(vF1)=$(v)) then
trace 'found match v=' $(v);
end if;
next v;
Thanks a lot, it worked!
Hi Alessandro,
the suggestion from Erica did the job - many thanks for your help.
Cheers.
Hi Massimo,
the suggestion from Erica did the job - many thanks for your help.
Cheers.