Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
We have implemented a listbox containing a numeric dimension, string and mixed expressions. We would like to sort all of these dimension and expressions seperately based on variables. For example;
If variable=1 sort based on dimension
if variable=2 sort based on expression1
if variable=3 sort based on expression2...
We accomplished all of these however we applied sorting on string and mixed expressions only for the first character. What we want is a proper ordering for all of the characters.
Example: 1230adf
13k
10b
alk
ayk
ac
bab
bzg
bbk
What we would like to do is:
10b
1230adf
13k
ac
alk
ayk
bab
bbk
bzg
The reason of the sort problem is caused by using "ord" function which is only concerned with the first character of the string. But we have to find a solution for sorting through all the characters. Is anyone ever had this problem before or could you help us with solving the problem and suggest another sort function.
Regards,
Hi,
maybe it is better define the sort order in the script, and then use an expression to choose the criteria.
Field, Sort1, Sort2, Sort3
13k | 1 | 2 | 3 |
alk | 2 | 3 | 4 |
ayk | 3 | 4 | 5 |
bbk | 4 | 5 | 6 |
bzg | 5 | 6 | 7 |
bab | 6 | 7 | 8 |
10b | 7 | 8 | 9 |
ac | 8 | 9 | 1 |
1230adf | 9 | 1 | 2 |
This is only for a limited number of records whereas we need a generic solution since we are dealing with a huge amount of data.
Well, in my cases espressions to sort are not working so fine, so I prefer set the sort in the script.
I found a discussion, but it is quite complicated...
I know this is an older post, but I updated an article which attempts to explain the algorithm for sorting of alphanumeric data in Qlik: https://support.qlik.com/articles/000005509
-Ken