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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
claudio1
Contributor III
Contributor III

Problem with listbox sorting

Hi,

I have a problem with the simple sorting of a list box, my situation is as follows:

Sort:

Sate: Ascending

Text: A -> Z

Expression inside the list box:

if (FIELD1 = 0, FIELD2)

Using any kind of expression as value of the listbox (like the one just described) the sorting of the listbox does not work properly when i apply any kind of selection on the data, in particular it seems that it loses the Sort by State. If i enter the direct value of FIELD2, so without applying an expression on the listbox value, sorting always works correctly (so the data is sorted by state and then alphabetically).

Anyone knows why this happens?

My QV version is 10 SR3.

Thank you in advance,

Claudio

1 Solution

Accepted Solutions
Not applicable

Hi,

In that case you can think of using Data Reduction using section access based on the user logged in.

Can you elaborate your requirement if you are still looking for some solution?

Cheers.

View solution in original post

8 Replies
Not applicable

Hi,

What i understood from your post is

That you have two fields based on one field you are capturing the data of another field in a listbox by writing expression like(=if(field1=0,Field2)) and the sort order is not working for you in this senario yes,

and if you take directly Field2 in a listbox then the sort order is working for you yes,

Now how can you desiding the sort order is not working in the first senario and what selections you are doing on that listbox?

Regards...........

claudio1
Contributor III
Contributor III
Author

Hi,

Yes what you understood is correct.

Basically i'm only using that expression as a filter on listbox values and then i am making a selection on the whole data using another dimension.

I think the problem is not the selection itself because i've tried a similar case on another report and i have the same issue : with the direct field sorting works, with an expression it doesn't (when you start to play with selections).

I've also tried with a dummy expression like this If(1=1, FIELD2) and i have the same issue.

It seems that using an expression in a listbox value causes this problem with sorting.

Anyone is experiencing the same problem?

Not applicable

Hi,

yes in Qlikview sorting wont work if you use expressions in the chart dimensions or filed list boxes.

If you want proper sorting you should create a new field while loading the data based on the expression you are giving in the field expression.

So in the load script you create new filed like

Load *,

     if(FIELD1=0,FIELD2) as NewField,

     from ssdsfs;

and apply waht ever the sorting you wanted.

Hope this helps you.

Cheers.

Not applicable

If you always want the sort order to be in a specific format - a possible way is to use ORDER BY in your load or sql select when loading your script.

claudio1
Contributor III
Contributor III
Author

Hi BlackRockS,

Your answer seems correct, unfortunately in my report i can't use such solution because in the listbox value i have something like this :

IF(USER='$(vUserName)', FIELD)

My filter expression on data is based on the variable vUserName which is set at runtime with the value of OSUser() (a QV function returning the name of the currently logged in user).

So, there is no way for me to apply that filter directly inside the Load script, not having that information yet.

Maybe there is a more suitable way to filter data using the currently logged in user?

Thank you!

Not applicable

Hi,

In that case you can think of using Data Reduction using section access based on the user logged in.

Can you elaborate your requirement if you are still looking for some solution?

Cheers.

claudio1
Contributor III
Contributor III
Author

I didn't know about Data Reduction, i read the manual and i managed to find a way to filter my data using section access with NTNAME. It works like a charm, and now i can finally avoid using an expression on my listboxes.

Thank you very much for your help!

Cheers.

Not applicable

Hi,

Glad it helped you.

Cheers.