Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
pepe2209
Creator
Creator

Sort with value X on top and the rest alphabetical

Hello,

I am looking to achieve this sort order in a list box:

Variable
X-value
A
B
C
D
E
F

Problem is that the values A, B, C etc. are extracted from an excel file the user can adjust. So the number of values and the naming of the values is variable. The X-value is added manually in the script but has to show on top of the listbox.

The following script in accordance with 'sort by load order' in the List box leads to the X-value being on top but the others not being sorted alphabetical.

Load * inline

[Variable

X-value];

join load distinct

Variable

from excel


Is it possible to achieve this? your help would be much appreciated.

Regards,

Peter

1 Solution

Accepted Solutions
tresesco
MVP
MVP

It's a feature. In that case, you have to bypass the selection. Try like:

Sort tab-> Expression: =If(Only({1}Variable)= 'X-value',1,2)         , with State and Text options are checked.

View solution in original post

6 Replies
tresesco
MVP
MVP

Sort tab-> Expression: =If(Match(Variable, 'X-value'),1,2)

and, check  'Text' - A->Z

MK_QSL
MVP
MVP

Check below link...

Custom sort order in chart

maxgro
MVP
MVP

1.png

pepe2209
Creator
Creator
Author

Thanks,

I used this but it still didn't work in the listbox.

But then I discovered that this is because the option 'Always One Selected Value' was checked. And I need this option... so is this a logic feature or is this a bug??

tresesco
MVP
MVP

It's a feature. In that case, you have to bypass the selection. Try like:

Sort tab-> Expression: =If(Only({1}Variable)= 'X-value',1,2)         , with State and Text options are checked.

pepe2209
Creator
Creator
Author

that did the trick, thanks