Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to force a sort on a listbox

I have a table that contains 2 columns,

     Producat_Cat_Name and Cross_Flag. From this table I need to create a listbox that looks as follows:

     Category1

     Category2

     Cross_Flag >>this one contains all the products that did not fit into the first 2 categories.

The listbox also needs to be sorted in the above way.

To do this I have created another table that has a sort order column, but its not working.

I have attached the App, please take a look at the properties of the Listbox.

My main problem is that once I add an expression to the sort then the fileds start to change position, looks like they are getting sorted by State, even thought I have that option disabled.

Let me know I need to provide more details.

7 Replies
raghvendrasingh
Creator II
Creator II

Hi Leo,

Please attach desired solution in excel.I am not much clear about this post.

Thanks & Regards,

Raghvendra Singh

Not applicable
Author

I have attached an excel spreadsheet.

I just want the list box to contain values Category1, Category2, Cross_Flag

and I need them to be Sorted in that way.

danieloberbilli
Specialist II
Specialist II

I would suggest to create a new dimension in the script instead of having an expression in the listbox...sorting is so much less a pain in creating a temp table with the desired sorting order and drop it at the end of the script. Then you can use the 'Load order' as sorting.

Please find attached

Not applicable
Author

would it still work if Im doing a binary load for my data?

danieloberbilli
Specialist II
Specialist II

I think not, as the binary load must come first.

Maybe the easiest would be to have a consecutive letter or number in front and use text order like

A) Cat 1

B) Cat 2

...

Z) Cross_Flag

Peter_Cammaert
Partner - Champion III
Partner - Champion III

You can use the dual() function in an initial/successive (after BINARY) load. This has a couple of advantages:

  • No weird listbox behaviour
  • No complex listbox expressions
  • Calculations are relegated to the script. If you can do it in your script, that's where you should do it.
  • Sort order is forced, whatever you do with it later on in the UI.

See if the attachment suits your needs.

Best,

Peter

Not applicable
Author

It almost worked,

But is there a bug in the software where the moment you enter any kind of expression in the Sort tab is automatically changes the sort by the state?

In other words, when I enter any expressions it begins to change the sorting after every click.