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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
danialier
Creator III
Creator III

List Box sort


Hello,

I have a list box as follows:

3m printers

5m printers

HE printers

hybrid printers

production above 80 printers

production from 50 printers

I want the list box to be sorted as follows:

HE printers

5m printers

3m printers

hybrid printers

production above 80 printers

production from 50 printers

How I can do that ? I did not find the way to do that through the sort options in the sort tabrow under the List Box properties...

Please help.

Thanks,

dani

1 Solution

Accepted Solutions
Nicole-Smith

Sort by expression:

match(YourField,

'HE printers',

'5m printers',

'3m printers',

'hybrid printers',

'production above 80 printers',

'production from 50 printers')

View solution in original post

9 Replies
Nicole-Smith

Sort by expression:

match(YourField,

'HE printers',

'5m printers',

'3m printers',

'hybrid printers',

'production above 80 printers',

'production from 50 printers')

danialier
Creator III
Creator III
Author

Hi Nicole,

This is what I did but it does not work…

Am I missing anything ?

Thks,dani

Nicole-Smith

You need to put whatever field has those values in the place where I have YourField:

match(YourField,

'HE printers',

'5m printers',

'3m printers',

'hybrid printers',

'production above 80 printers',

'production from 50 printers')

Anonymous
Not applicable

You forgot to put the field name as the first argument in the expression.

Not applicable

HeY Dani,

I think you forgot the field name.

Thanks

AJ

giakoum
Partner - Master II
Partner - Master II

I would suggest using the dual function. Adding an order number to each value. This way sort would be much more efficient with QV.

Dual

dual( s , x )

Forced association of an arbitrary string representation s with a given number representation x. In QlikView, when several data items read into one field
have different string representations but the same valid number representation,
they will all share the first string representation encountered. The dual
function is typically used early in the script, before other data is read into
the field concerned, in order to create that first string representation, which
will be shown in list boxes etc.

Example:

load dual ( string,numrep ) as DayOfWeek inline 

[ string,numrep

Monday,0

Tuesday,1

Wednesday,2

Thursday,3

Friday,4

Saturday,5

Sunday,6 ];

load Date, weekday(Date) as DayOfWeek from afile.csv;

The script example will generate a field DayOfWeek
with the weekdays written in clear text. QlikView will for all purposes (including sort) regard the field as a numeric field.

danialier
Creator III
Creator III
Author

Excellent now it works !!!

However when I select a filter, the selection goes to the bottom of the list box… and I want this list box to be fixed whatever value I select from the List Box. Do you know how to do that ?

Thanks !

dani

Nicole-Smith

match(only({1}YourField),

'HE printers',

'5m printers',

'3m printers',

'hybrid printers',

'production above 80 printers',

'production from 50 printers')

danialier
Creator III
Creator III
Author

Excellent !!!! It works now. Many thanks Nicole !