Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Peony
Creator III
Creator III

How to set field values as variable?

Hi everyone.

In my script now I create variable like this:

Set vVar  = 'AAA', 'AAAB', 'CC','DD.FF.G>kYY';


This variable I use in the script with "Match" function.

Since I need to take values foe this variable from the particular field, I tried to do next variants, to get field values into the same variable. Unfortunately, both didn't give me any result. 

First solution:

Table_1:
Load 
Chr(39) & Field_1 & Chr(39) as Field_1 
From Table_123;

Let noRows = NoOfRows('Table_1')-1;

For i=0 to $(noRows)

Let vVar  =FieldValue('Field_1 ',$(i));

Next i

Second solution:

Table_1:
Load 
Chr(39) & Field_1 & Chr(39) as Field_1 
From Table_123;

Set vOBR_Assets = Peek('Field_1 ', 0, 'Table_1');

In both cases vVar is empty. Any suggestion how to solve this task?

Labels (2)
1 Solution

Accepted Solutions
tresesco
MVP
MVP

Are you trying to get all the values from a field? If so try like:

Load
    Concat(Distinct  char(39) & Field_1 & chr(39), ',') as ConcatString
From <>;

Let vVar = Peek('ConcatString');

 

View solution in original post

4 Replies
tresesco
MVP
MVP

Are you trying to get all the values from a field? If so try like:

Load
    Concat(Distinct  char(39) & Field_1 & chr(39), ',') as ConcatString
From <>;

Let vVar = Peek('ConcatString');

 

DavidM
Partner - Creator II
Partner - Creator II

Hi,

in the first solution, your variable gets overwritten with each iteration and I guess there might be more rows than actual values, so you get NULL. If you want to do it this way, you need to append the new value to old variable. Btw you don't need to create variable noRows.

 

In the second my guess is the extra space in 'Field_1 ' in Peek function

 

Peony
Creator III
Creator III
Author

Tresesco, your idea it's a perfect match! Thank you for help. 

Peony
Creator III
Creator III
Author

David, thank you much for your advises.