Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
gsethuraman2
Contributor III
Contributor III

how data from query multiple rows assign to single variable as comma separted

I need something like this ..

set vPERSONID=Aggr(Concat(DISTINCT PERSONID, ', '));

 

Query Output from database

PERSONID

28987

145672

675432

 

i need something like this in below variable ..

 

vPERSONID=(28987,145672,675432)

 

 

 

 

 

3 Solutions

Accepted Solutions
mahaveerbiraj
Creator II
Creator II

HI 

Refer below example 

Data:

Load * inline

[

Num

1

2

3

4

];

TempConcat:

LOAD Concat(Distinct Num,', ') as TempNum Resident Data;

Let val = FieldValue('TempNum',1);

 

Reply me if your not clear with example.

View solution in original post

gsethuraman2
Contributor III
Contributor III
Author

Yes its getting full set of value thru resident load .. 

 

thanks .. so it solved rather putting for loop for 30 or 40 ID's per manager its taking time ..

so this way per manager ID whoever reports will get his list in single variable thru comma separated and i parse that value to further queries ..

 

thanks .. it helped .. 

View solution in original post

gsethuraman2
Contributor III
Contributor III
Author

Getting data for iterative loop worked .. By dropping loading data

for example i=0 

set the comma separted value then after in the bottom i dropping 

DROP Table Data

 

So next time with new i val its getting new set of comma separted value ..

 

thanks ..

View solution in original post

7 Replies
Ezir
Creator II
Creator II

 

set vPERSONID=Concat(TOTAL PERSONID,', ')

 

Ezir
Creator II
Creator II

Hello @gsethuraman2 

 

Did it work?

mahaveerbiraj
Creator II
Creator II

HI 

Refer below example 

Data:

Load * inline

[

Num

1

2

3

4

];

TempConcat:

LOAD Concat(Distinct Num,', ') as TempNum Resident Data;

Let val = FieldValue('TempNum',1);

 

Reply me if your not clear with example.

gsethuraman2
Contributor III
Contributor III
Author

set vPERSONID=Concat(TOTAL PERSONID,', ');


trace $(vPERSONID);

 

its printing me as string val - Concat(TOTAL PERSON_IDENTIFIER,', ')

Not sure anything iam missing in the code ???

gsethuraman2
Contributor III
Contributor III
Author

Yes its getting full set of value thru resident load .. 

 

thanks .. so it solved rather putting for loop for 30 or 40 ID's per manager its taking time ..

so this way per manager ID whoever reports will get his list in single variable thru comma separated and i parse that value to further queries ..

 

thanks .. it helped .. 

gsethuraman2
Contributor III
Contributor III
Author

TempConcat:

LOAD Concat(Distinct Num,', ') as TempNum Resident Data;

Let val = FieldValue('TempNum',1);

 

this work for first set of rows ..  (i=0 it pulled all comma separated value correctly)

 

then thru second load which i do in loop i=1 that i parse new variable to the query then i need new comma separted value but iam getting same value as above in that val$(i) .. its because iam using resident load ..as its getting value only for first set correctly 

 

 

gsethuraman2
Contributor III
Contributor III
Author

Getting data for iterative loop worked .. By dropping loading data

for example i=0 

set the comma separted value then after in the bottom i dropping 

DROP Table Data

 

So next time with new i val its getting new set of comma separted value ..

 

thanks ..