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

Putting multiple selected values in one row?

Hi guys,

Is there an easy way to use something like 'SELECT STUFF ... FOR XML PATH' in SQL?

I'm trying to create a table with title like this:

Analysis for: 2014 (when one year is selected)
Analysis for: 2012, 2013, 2014 (when more than one year is selected).


I need a function that puts all selected values (ike Year in this example) and a comma between them. My current expression is:
='Analysis for: ' & Only(Year) (because I only know how to put only one value).
Can you help me?

Thanks a lot!

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

Use the concat function like:

='Analysis for: ' & concat(distinct Year, ',')


Or you could also use GetFieldSelections(Year)


Hope this helps!

View solution in original post

3 Replies
jerem1234
Specialist II
Specialist II

Use the concat function like:

='Analysis for: ' & concat(distinct Year, ',')


Or you could also use GetFieldSelections(Year)


Hope this helps!

Not applicable
Author

i agree with jerem1234´s solution

concat writes every item in the selected field (Year) after each other.

here, the function distinct is added, to prevent redundancy (2013, 2013, 2014).

The last option is the separator, which is entered between the field contents

concat(distinct Year, ',')


i would suggest to ad another space to the seperator

concat(distinct Year, ' ,')


Not applicable
Author

This certainly helps, I combined this solution with GetSelectedCount() to avoid putting all values in title when nothing is selected.


Thanks a lot for your swift answer!

Best regards,
Pawel