Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Highlighted
Tuzlukov
New Contributor

Getting table values into a variable

Hi,

I have a column (ColumnName) in some table with values:

A

B

C

...

Z

And i want to put all of the values into the variable (vValues), to get comma separated values in one string like this:

vValues = 'A,B,C,...,Z'

How can i do this? Tried 'concat' but unfortunately it does not work 😞 

1 Solution

Accepted Solutions
Partner
Partner

Re: Getting table values into a variable

Hello,

you should make a loop and use the function peek().

Somethinkg like this

 

for N=0 to NoOfRows('TableName')-1

    let vValue$(N)=peek('fieldName',N,'TableName')

next;

and concat all values.

J.

View solution in original post

7 Replies
Partner
Partner

Re: Getting table values into a variable

Hello,

you should make a loop and use the function peek().

Somethinkg like this

 

for N=0 to NoOfRows('TableName')-1

    let vValue$(N)=peek('fieldName',N,'TableName')

next;

and concat all values.

J.

View solution in original post

Surya
Contributor

Re: Getting table values into a variable

Hi,

Do simply..

in variable overview > add variable > vVariable and value

=concat(fieldname,',');

 

i think this is enough...

Tuzlukov
New Contributor

Re: Getting table values into a variable

Looks good, but it does not work when i use it in script editor. This expression returns empty vValues:
LET vValues = Concat(ColumnName,',')
Surya
Contributor

Re: Getting table values into a variable

YOU JUST TRY front end ...

 

in edit script using end and using "LET"

MVP & Luminary
MVP & Luminary

Re: Getting table values into a variable

You need an aggregation-load for it if you want to do it in the script, like:

t: load concat(Field) as ConcatField from source;

and the you could pick the value from the table, like:

LET vValues = peek(ConcatField,0, 't');

What is the aim for this list?

- Marcus

Tuzlukov
New Contributor

Re: Getting table values into a variable

Aim of the list is future list of column names for crosstable.

Finaly my request looks like:

CrossFields:
LOAD
ColumnName
Resident tmp2;
LET CrossFieldsList = Concat(ColumnName,',','CrossFields');

And after reloading data i see CrossFieldsList as empty variable.

Tuzlukov
New Contributor

Re: Getting table values into a variable

Looks like the loop is the better way to get the string. Thanks a lot!

I use this code:

FOR i = 0 TO FieldValueCount('ColumnName')-1
LET CrossFieldsList = IF(CrossFieldsList='','',CrossFieldsList & ',') & '[' & Peek('ColumnName',i,'CrossFields') & ']';
NEXT i;