Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Pick function and string values

Hello al, I have some problems with the Pick function;

I make a string with several names in it which i want to use later on in a variable;

Scenario 1;

Let vLevelNames='Naam 1'&','&'Naam 2'&','&'Naam 3'&','&'Naam 4'&','&'Naam 5'&','&'Naam 6';

Let vLevelName=Pick(1,$(vLevelNames));


I Get the next error;


Error in expression:
')' expected
Let vLevelName=Pick(1,Naam 1,Naam 2,Naam 3,Naam 4,Naam 5,Naam 6)

Scenario 2;
Let vLevelNames='Naam 1'&','&'Naam 2'&','&'Naam 3'&','&'Naam 4'&','&'Naam 5'&','&'Naam 6';

Let vLevelName=Pick(1,$(vLevelNames));

I get no error and also na value for vLevelName


Scenario 3;

Let vLevelNames=10&','&11&','&12&','&13&','&14&','&15;

Let vLevelName=Pick(1,$(vLevelNames));


Works perfectly, no errors and value 10 for vLevelName

Does anyone know why scenario 1 and 2 don't work, and what to do to get them work. Thnx in advance.

Greetz Sander

1 Solution

Accepted Solutions
Highlighted

Pick function and string values

Hello Sander,

You were almost there. When it comes to literals or strings, you need to single quote them. There are two ways of doing that using variables, depending on whether the assignment is done by LET or SET:

SET vLevelNames='Naam 1','Naam 2','Naam 3','Naam 4','Naam 5','Naam 6'; // This stores as a literal, not evaluating the content, s no need to use & between valuesLET vLevelNames = chr(39) & 'Naam 1' & chr(39) & ',' & chr(39) & 'Naam 2' & chr(39) & ',' & chr(39) & 'Naam 3' & chr(39) & ',' & chr(39) & 'Naam 4' & chr(39) & ',' & chr(39) & 'Naam 5' & chr(39) & ',' & chr(39) & 'Naam 6' & chr(39); // LET does evaluate the assignment, so chr(39) is translated into ' symbol, needed to quote the results in order to get Pick() working


The LET option is cumbersome, but it may be useful in the future when you do need evaluation of the assignment.

Hope that helps

View solution in original post

2 Replies
Highlighted

Pick function and string values

Hello Sander,

You were almost there. When it comes to literals or strings, you need to single quote them. There are two ways of doing that using variables, depending on whether the assignment is done by LET or SET:

SET vLevelNames='Naam 1','Naam 2','Naam 3','Naam 4','Naam 5','Naam 6'; // This stores as a literal, not evaluating the content, s no need to use & between valuesLET vLevelNames = chr(39) & 'Naam 1' & chr(39) & ',' & chr(39) & 'Naam 2' & chr(39) & ',' & chr(39) & 'Naam 3' & chr(39) & ',' & chr(39) & 'Naam 4' & chr(39) & ',' & chr(39) & 'Naam 5' & chr(39) & ',' & chr(39) & 'Naam 6' & chr(39); // LET does evaluate the assignment, so chr(39) is translated into ' symbol, needed to quote the results in order to get Pick() working


The LET option is cumbersome, but it may be useful in the future when you do need evaluation of the assignment.

Hope that helps

View solution in original post

Highlighted
Not applicable

Pick function and string values

Thnx, this is the solution!!Smile