Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
suhle1234
Contributor
Contributor

define a simple array

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!

3 Replies
albertovarela
Partner - Specialist
Partner - Specialist

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 

 

suhle1234
Contributor
Contributor
Author

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.

 

piri1069
Contributor II
Contributor II

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.