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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Order of text values

Hi.

I have a problem with ordering the values of a field in a list box.

In a products table I have a group field (gp), a code field (code), a description field (desc) and a field named "IDProduct" which result from concatenate the other three:

gp&' | '&code&' | '&desc as IDProduct

In the list box I select "Order by text" and the result is this:

list_box.png

But the correct order should be like this:

excel.png

Could anyone help me solve this?

Thanks in advance.

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

What QlikView calls Text Order is what is often called "Natural Sort" these days. Look up the term in Wikipedia for a full explanation.

Strangely enought the Load Script does "Natural Sort" while the chart engine does an ASCII-sort. That is why Sinan's suggestion works.

If you want to force QlikView to do an ASCII-sort in the Load Script - this is a way you can do it:

2015-09-09 #1.PNG

The vertical bar that gets inserted between each digit will break the Natural Sort of QlikView so it will do a character by character sort as there will be no more consecutive digits anymore. MapSubstring() function will insert these vertical bars and then doing a RESIDENT load with an ORDER BY on this new temporary field we can get the correct sort order and assign it by using RowNo(). By combining the the product string with the sort order number into a dual field named Product we achieve that QlikView will use the number to denote the sorting order of this field but use the string as the displayed part of the same.

View solution in original post

7 Replies
sinanozdemir
Specialist III
Specialist III

Hi,

I tried the below expression in a list box:

Capture.PNG

And then, sort it as text in an ascending order:

Capture1.PNG

Hope this helps.

Not applicable
Author

Thanks, it works.

But I have nearly 250 thousand records in the products table besides other tables in the app. So this solution will slow down the app.

qlikviewwizard
Master II
Master II

Hi,

Use autonumber(gp&' | '&code&' | '&desc) as IDProduct.

Later sort the column on number which is very faster. Hope this will help you.


petter
Partner - Champion III
Partner - Champion III

What QlikView calls Text Order is what is often called "Natural Sort" these days. Look up the term in Wikipedia for a full explanation.

Strangely enought the Load Script does "Natural Sort" while the chart engine does an ASCII-sort. That is why Sinan's suggestion works.

If you want to force QlikView to do an ASCII-sort in the Load Script - this is a way you can do it:

2015-09-09 #1.PNG

The vertical bar that gets inserted between each digit will break the Natural Sort of QlikView so it will do a character by character sort as there will be no more consecutive digits anymore. MapSubstring() function will insert these vertical bars and then doing a RESIDENT load with an ORDER BY on this new temporary field we can get the correct sort order and assign it by using RowNo(). By combining the the product string with the sort order number into a dual field named Product we achieve that QlikView will use the number to denote the sorting order of this field but use the string as the displayed part of the same.

petter
Partner - Champion III
Partner - Champion III

2015-09-09 #2.PNG

Not applicable
Author

This is what I'm looking for, thanks!

I just added the letters of the alphabet to the mapping table since the group ID is alphanumeric.

And also it works without the Dual function for the Product field, I just set the order by load.

Thanks a lot for your help.

petter
Partner - Champion III
Partner - Champion III

Then you should close this thread an mark it as answered