Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using 2nd selected value as a Dim in Alternate State

Hello everyone!

Is it possible to use only 2nd, 3rd, 4th from the top of selected values in listbox?

For example: I'd like to use 2nd or 3rd value from the top of selected values in listbox and use it as a dimension in table with Alternate State.

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Dimension: YourField

Expression: Sum({<YourField={"$(=Subfield(Concat(Distinct YourField, ';'), ';', 2))", "$(=Subfield(Concat(Distinct YourField, ';'), ';', 3))" }>} Measure)

Hope this helps you.

Regards,

Jagan.

View solution in original post

8 Replies
tresesco
MVP
MVP

One way to get

2nd value - Subfield(Concat(Distinct YourField, ';'), ';', 2)
3rd value - Subfield(Concat(Distinct YourField, ';'), ';', 3)

Note, here sorting of the field values/load order would play an important role to decide which value comes first but the order of selection.

Anonymous
Not applicable
Author

I know But how can I use it as a dimension?

tresesco
MVP
MVP

Could you please share a sample qvw explaining the requirement a bit more in detail?

vincent_ardiet
Specialist
Specialist

Hi,

You can try to use a IF in your dimension which can be poor in performance but it depends on the size of your application.

For example with something like this in the dimension expression and a dimension limit to have only 2 values displayed:

 

=if(match(NAME,$(=mid(concat({$}distinct NAME,chr(39)&','&chr(39)),index(concat({$}distinct NAME,chr(39)&','&chr(39)),chr(39)&','&chr(39))+2)&chr(39))),NAME)

Anonymous
Not applicable
Author

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Dimension: YourField

Expression: Sum({<YourField={"$(=Subfield(Concat(Distinct YourField, ';'), ';', 2))", "$(=Subfield(Concat(Distinct YourField, ';'), ';', 3))" }>} Measure)

Hope this helps you.

Regards,

Jagan.

jagan
Luminary Alumni
Luminary Alumni

Please find attached file for solution.

Regards,

Jagan.

Anonymous
Not applicable
Author

Dimension: YourField

Expression: Sum({<YourField={"$(=Subfield(Concat(Distinct YourField, ';'), ';', 2))","$(=Subfield(Concat(Distinct YourField, ';'), ';', 3))" }>} Measure)

That helped. Thank you