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

Listbox Expression sort problem

Hi guys,

I've faced a problem trying to sort values in a listbox populated by the expression:

=if(EntryType = 'PR',
Project,
null()
)



The sort rule is:

State = "Auto Ascending"
Text = "A->Z"

Whenever any value from other fields is selected, the values of the listbox remain on their places although the possible values should be displayed first according to the sort rule.

The listbox with any field gets sorted perfectly well while it seems that it does not like expressions for sorting.

Are there any ideas how to solve the problem?

Thanks.

Valera



29 Replies
deepakk
Partner - Specialist III
Partner - Specialist III

I am not sure but try this...

=if(EntryType = 'PR' and len(trim(Project)) >0, Project)

Anonymous
Not applicable
Author

Well, as expected, the empty string disappeared, but the sort order remained intact:

deepakk
Partner - Specialist III
Partner - Specialist III

try this...

=if(EntryType = 'PR' and len(trim(Project)) >0, trim(Project))

Apply the same in Expression Sorting and say Ascending.. it should work

Anonymous
Not applicable
Author

Hi Deepak,

Thanks for the suggestion. However, it does not change the situation. The sorting keeps not working.

Moreover, I can't continue excluding the empty strings from the listbox. In fact, I have a field Project and a field ProjectDescription. So, I display the project descriptions and there are some projects with empty descriptions. Still, I want to see them.

The Project table contains the fields Project, EntryType, ProjectDescription. So, by using the EntryType field I can populate the listbox only with the relevant project descriptions.

That's why my expression is:

=if(EntryType = 'PR', ProjectDesc)

As for the sort rule, it seems that I am forced to use both the State option, the Expression option and the Text option. If the Text option is excluded, the list remains simply unsorted. If the Expression option is excluded, the list remains sorted well, but the excluded items are simply marked as excluded and not moved to the end of the list.

This seems to be a kind of a QV bug or there is problem in the expression itself... Any further ideas?! 🙂

Thanks! 🙂

deepakk
Partner - Specialist III
Partner - Specialist III

if you can attach the applictaion I can give it a try.........

Anonymous
Not applicable
Author

The easiest approach would likely be to define the expression as a field in the script already and it will sort correctly in the listbox when you add it in your layout.

Anonymous
Not applicable
Author

Hi Johannes,

I've tried to create an "artificial" field as an expression and could not find a way to do it. The only possibility was creating a group with an expression. When I use this group in the listbox the sorting seems to work perfectly.

However, the use of the group implies the display of a group symbol (either Cyclic or DrillDown) on the listbox which is confusing.

Are there other ways to create "artificial" fields?

Thanks.

Anonymous
Not applicable
Author

Anyway, guys, find attached the application with the problem.

I guess there is some problem with the data because when I tried to load fewer records the sorting seemed to work fine... I'm definitely missing something. 🙂

Thanks for help! 🙂

P.S. When you open the application, you will see this list already:

deepakk
Partner - Specialist III
Partner - Specialist III

HI Valera, I dont the reason but if you remove the State from sorting and Use Descending in Expression then it seems to be working fine...

But i dont know y its behving in this fashion....

Surprise

Anonymous
Not applicable
Author

Thanks for the suggestion, Deepak.

I removed the STATE from sorting, but then I have the old problem of excluded values inside the list (not in its end) back.

And, strangely, I see that the list itself is not sorted properly when EXPRESSION option is used. The list is sorted well only if its values are treated as TEXT. But the STATE option is ignored by QV in this case.

Thanks for suggestion.