Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I'm a beginner in scripting Qlik
I want to define an array an store 3 string in it.
This is not working:
Dim vSpedi
'my example:
'set vYears = '2008','2009','2010'
'Then use the for each:
'for each y in $(vYears)
'statements...
'next
set vSpedi = 'string1','string2','string3'
What's wrong??
Thank you!
It will be helpful if you could provide more detail on what you are trying to achieve. To get the For/Next working try:
FOR Each vYears in '2008', '2009', '2010'
Statements....
//You can store the String values in a table
Next
Hi
first of all, Thanks.
I'm trying to stroe Strings in an array and run then a for each loop for every value.
Dim vSpedi
set vSpedi = 'string1','string2','string3'
for each i in vSpedi
end for
I will try your proposal.
Thanks in advance.
How about placing the values in the array using Peek() function ?
First you place your values in a table (or get distinct value from table)
Second, place the values you want into the array by using CONCAT function. The chr(39)is for an apostrophe to identify the value. The ',' is to identify how the values are separated.
Third, use the PEEK function to place values into variable.
Last, drop tables not needed.
Here is an example:
YearsTable:
Load * Inline
[Years
2008
2009
2010
];
LookUp:
Load
Concat(chr(39) & Years& chr(39), ',') as YearLookUp
Resident YearsTable;
Let vYears = Peek('YearLookUp',0,'LookUp');
Drop Tables YearsTable, LookUp;
Hope this helps.
Pedro.