Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

List box re-sorts when I select an item

I have some list boxes that I need to sort in a particular order. So I have been sorting them by an expression. I've tried using a match function in the expression, which sorts them how I need them, and I've tried a map in the load script which also works, then i add that sort item to the expression.

However, once I select an item in the list box, the whole list re-sorts itself so that the selected items are at the bottom of the list. How do I change that behavior so that the list stays put, even when items are selected?

1 Solution

Accepted Solutions
Not applicable
Author

OK, I figured out what I was doing wrong. When I use the Dual function I also use the applymap function to determine the order for the object. I then name this new object ObjectSort. You have to use the ObjectSort object in field property to display AND you have to sort it numerically.

When you create afield like this in your data model QlikView will treat it as number and use thenumeric value when doing mathmatical operations (+, -, /, *, etc...) andas string when doing string operations (&, MaxString, Index, etc..). 

View solution in original post

4 Replies
Not applicable
Author

OK, I figured out what I was doing wrong. When I use the Dual function I also use the applymap function to determine the order for the object. I then name this new object ObjectSort. You have to use the ObjectSort object in field property to display AND you have to sort it numerically.

When you create afield like this in your data model QlikView will treat it as number and use thenumeric value when doing mathmatical operations (+, -, /, *, etc...) andas string when doing string operations (&, MaxString, Index, etc..). 

View solution in original post

fbl
Contributor II
Contributor II

Could you perhaps post a small example, I have the same situation, and cannot follow your explanation.

regards Frank

Not applicable
Author

This is what I did. I create a mapping for my section like this:

//Section Sort

SectionSort:

Mapping Load * Inline [

x, y

"First Section", 1

"Second Section", 2

"Third Section", 3

];

Then when I load the data from my query, I created a "SectionCaptionSort" objects like this that uses that mapping ([SectionCaption] is the database field that contains the sections like "First Section", "Second Section" etc):

, dual([SectionCaption],ApplyMap('SectionSort',[SectionCaption])) As "SectionCaptionSort"

Then you use the field you created "SectionCaptionSort" as the field to be displayed in your list box (the field box on the General tab of the list box's properties).

Then go to the "Sort" tab and uncheck everything. Check "Numeric Value" and sort it Ascending.

fbl
Contributor II
Contributor II

In the meantime, I found another way to do it, but I dont know if it's bullet-proof:

Strings to sort are Quarter-FiscalYear concatenations like

Q110, Q210,Q310,Q410,Q111,Q211 where the first 2 characters are the Quarter, the last 2 are the FiscalYear

I use this as the sorting expression:

Only({1}Right(Period,2))

It seems to work also, but not deeply tested yet.