Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
bhorneber
Partner - Contributor III
Partner - Contributor III

Sorting by expression in list box

Hi,

I am struggling with the sorting behavior in list boxes and can't figure out how to make it work.

I have a couple of list boxes with multiple entries that I want to have sorted in a specific order. When selecting one or more elements, the selected elements should come first, then the not selected elements. The important part: Also the not selected elements should keep their order.

To maintain my sorting order, I added a separate 'sorting column' to my data model.

This is a simpli !fied example with just for entries:

Data:

LOAD * Inline [

  Letter, Sort

  H, 10

  P, 40

  L, 30

  E, 20

];

My expectation was that having the following settings in my list box should work correctly:

screenshot1.JPG

Unfortunately, although the sorting works when not selecting anything, the order gets messed up when selecting e.g. the letter 'L':

screenshot2.JPG

Again, my expectation was to have L on top, and then H > E > P below. But somehow the sorting order only applies to the selection.

Any ideas how to fix that or why this behavior happens?

1 Solution

Accepted Solutions
sunny_talwar

Try this sort expression:

=Only({1} Sort)

Capture.PNG

View solution in original post

5 Replies
sunny_talwar

Try this sort expression:

=Only({1} Sort)

Capture.PNG

bhorneber
Partner - Contributor III
Partner - Contributor III
Author

Quick and easy. Thanks a lot!

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

As Sunny has pointed out, your values for "Sort" are not available when you make a selection, and the {1} will fix that.

I'd like to suggest that it may be easier to  deal with this by using "Load Order", rather than an expression.

Establishing a Sort Order | Qlikview Cookbook

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

bhorneber
Partner - Contributor III
Partner - Contributor III
Author

Thanks, Rob.

I thought about using load order as well and might play around with that a little more too.

Given the layout of the data sources and the data model in general, having a separate column is my preferred solution at this point. But as always, it's great to have some alternatives available.

paul8pharma
Contributor III
Contributor III

Thank you! This 5 year old post has helped me solve a problem I've had for a couple of days.