Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Listbox - text sort not ASCII?

Here's a hopefully quick question about listbox sorts, although I suspect it applies everywhere. My listbox is configured to sort by state (auto-ascending) and text (A-Z). My content is reformatted address data, and the numeric portion of my data is being sorted numerically. So I'm getting, for example,

POBOX1

POBOX2

POBOX100

POBOX200

instead of

POBOX1

POBOX100

POBOX2

POBOX200.

Am I missing something fundamental? I thought the nature of a text sort would be pure ASCII, but apparently it's not. The latter sort is what I'm trying to achieve. Thank you.

37 Replies
Clever_Anjos
Employee
Employee

Weird...

Into my tiny app it´s making correct selections

Capturar.PNG.png

PFA my app

Not applicable
Author

Try this in your script to see what I mean:

SortOrder:

LOAD Field & ' ' as Field INLINE [

    Field

    09MAINST

    8MAINST

    9MAINST

    POBOX1

    POBOX2

    POBOX100

    POBOX200

];

Edit: Hold that thought. It does seem to be sorting the values above correctly.

Clever_Anjos
Employee
Employee

I´m not proposing concatenating into script, only into listbox

Not applicable
Author

Right, but then nothing in the listbox is selected when values from other listboxes are selected.

Clever_Anjos
Employee
Employee

Am I missing something?

It seems to select here.

Capturar.PNG.png

Not applicable
Author

You're correct. It is selecting them. I'm seeing a completely different problem now. Instead of moving the selected values to the top of the list, it selects them in place. And as I'm dealing with tens of thousands of records, that wasn't apparent until I started scrolling through the list.

Another problem with this approach is that strings that are numbers by themselves are still sorted numerically first.

SortOrder:

LOAD Field & ' ' as Field INLINE [

    Field

    0

    09

    009

    0009

    1

    02

    5

    POBOX1

    POBOX100

    POBOX2

    POBOX200

];

09 is sorted after 5 (it should be sorted after 0).

Notice too that 09, 009 and 0009 are all treated as one value, which I absolutely don't want (though I don't believe that's symptomatic if you're solution).

Clever_Anjos
Employee
Employee

=text(if(len(Field & ' ')>1,Field & ' ')) will fix this

Not applicable
Author

That does work better. Thank you. But I still have the problem whereby it's not moving selected values to the top of the list. I believe it has to do with the volume of data. There is some lag between selections.

Clever_Anjos
Employee
Employee

Mark "State" to Ascending

Not applicable
Author

My day just ended. Will try it first thing Monday. Thanks for your help!