Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
chrweber
Creator
Creator

Pick ith element from concat or similar

Hi, I wish to pick the i'th element of a concatenated selection

=pick(1, concat( [Field], ', ' ))

I would have thought that I should be possible however, currently the second argument is interpreted as a single argument and not as many.

Is my approach possible and am I just missing something?

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hi Christoph,

Try this. You can use distinct inside the concat function, if you have duplicate values in the input field.

=Pick(1, $(=Concat( Chr(39) & [Field] & Chr(39), ', ')))

View solution in original post

22 Replies
MK_QSL
MVP
MVP

You can use something like below..

=SubField(Concat(DISTINCT [Field],', '),',',1)

//The above one is for picking 1st item

=SubField(Concat(DISTINCT [Field],', '),',',2)

// This is for 2nd item and so on

tamilarasu
Champion
Champion

Hi Christoph,

Try this. You can use distinct inside the concat function, if you have duplicate values in the input field.

=Pick(1, $(=Concat( Chr(39) & [Field] & Chr(39), ', ')))

chrweber
Creator
Creator
Author

Yes. This was the combination I was looking for.

Is there a distinction between the two?

tamilarasu
Champion
Champion

Sorry. Which two you are asking?

chrweber
Creator
Creator
Author

=Pick(1, $(=Concat( Chr(39) & [Field] & Chr(39), ', ')))


vs


=SubField(Concat(DISTINCT [Field],', '),',',1)

chrweber
Creator
Creator
Author

Iterating on that, I would like to use that further so that I can use the single value in some elaborate expression:

Something like:

=only({$<[Field]={$(=SubField(GetFieldSelections( [Field],', ',3),',',1))}>}  [Field])

But I do not understand the parsing of expressions good enough yet.

tamilarasu
Champion
Champion

Both will show the same result. If you want to check how it is working, you can create a straight table and leave the dimension tab blank and add your expression like below. This way you can easily identify how the expression is parsing the value and debug your expression if required.

Capture.PNG

BTW, you have to add single quotes.

=only({$<[Field]={'$(=SubField(GetFieldSelections( [Field],', ',3),',',1))'}>}  [Field])

tamilarasu
Champion
Champion

If you got the solution, please close the thread by marking correct and helpful answers.

chrweber
Creator
Creator
Author

Thank you, the placement of char(39) is still a mystery to me.

Interestingly, it appears that I cannot select the second element

=only({$<[Field]={'$(=SubField(GetFieldSelections( [Field],', ',3),',',2))'}>}  [Field])

What am I missing here?