Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Sorting the values in a listbox when using an expression in the sort tab

Hi

I want to know if anyone knows how to sort the values in a listbox, when one is forced to have an expression in the sort tab?

I had to use the same expression from the general tab in the sort tab

if(datakilde='Aarlig', Aktivitetsnavn)

-  otherwise the listbox didn't show the associated values (from a selected value from another listbox) in the top of the listbox - which aren't very user friendly.

But as a consequence the sorting in alphabetic order is no longer works...

See my sort tab below.

Kind Regards Maria

112.png

12 Replies
Anonymous
Not applicable
Author

I used the sorting expression whe I tried Ascending in stead of auto ascending. I have to have that expression, because the variable "aktivitetsnavn" have a filter (daily data versus yearly data). Ypu can see that I have the same expression in the general tab - because I only want to have shown a subset of the values of the variable "aktivitetsnavn".

Anonymous
Not applicable
Author

I can see that you deleted the expression in the sort tab?

I have to have the expression, otherwise the associated values in the listbox "Aktivitetsnavn" doesn't appear in the top, when I choose a value in the listbox "Fakultet".

I found out that I had this problem because I had to use an expression in the general tab.

If I only had chosen a variable from my data  set (instead of writing an expression), I wouldn't have any problems with the sorting in the listbox and I wouldn't have any problems with the associated values not being shown in the top of the listbox.

BUT I have to use the expression in the genereal tab, becuase otherwise I get too many values in the listbox - and in the one sheet I only need data with the daily data and in the other sheet I only need the yearly data being shown.

I discovered that because of the expression in the general tab, I had to copy the expression into the sort tab also - otherwise the  associated values didn't appear in the top of the listbox. But this resulted in the values in the listbox not being shown in alphabetic order.

Anonymous
Not applicable
Author

I got a tip from Stackoverflow that said:

There are multiple solutions on this, but I think the correct one, would be to create a field in your datamodel, that contains just the values that need in the listbox.

Listboxes are not very good at filtering data. So take your if statement, and put it into the source table:

if(datakilde='Aarlig', Aktivitetsnavn) as Aktivitetsnavn_2

Then you don't have to struggle with filtering data in listboxes and your sorting will be correct.

After I put the if statement in the script instead of the listbox, it worked. Now I don't need to use an expression in the general tab and because of that I don't have any problems with the associated values not being shown i the top of the listbox. And therefore I don't need the expression i the sort tab either- which now has resulted in no problems with the sorting in the listbox.