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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
imsohotness
Contributor
Contributor

Sort by Expression not working

Good morning everyone, 

I'm trying to use the Match function to custom sort text values in a certain field for my pie charts, but it doesn't work. Here is my expression: 

=Match([Item 3: Length of Service],'More than 5 years','3-5 years','1-2 years','Less than 1 year')

 

Here is a quick video explaining my issue. Sorry for the poor sound quality.

 

10 Replies
sergio0592
Specialist III
Specialist III

Hi,

Where do you want to sort? In a stacked bar?

imsohotness
Contributor
Contributor
Author

Trying to do a Pie chart. I want the values to show up in the correct order in the legend.
sergio0592
Specialist III
Specialist III

When i create a sample with your formula, i have a correct order. In lengend settings, have you tried "reverse order"?

Legend.png

imsohotness
Contributor
Contributor
Author

I have tried to reverse the sort order, but to no avail. 

 

Here is a quick video explaining my issue. Sorry for the poor sound quality.

 

Seems like it should be so straightforward but it's not and its driving me crazy. 

Thanks for your help.

Or
MVP
MVP

I think you might be in the wrong forum, looks like you're asking about Qlik Sense, not QlikView...

When dealing with sorting issues, I've always had the most luck by setting up the fields in question as Dual() types in my script (you can also create a duplicate of the field in your script as a dual and keep the original), with the numeric aspect then used to control the sort order. If you only have four values, which seems to be the case, you should be able to do that without too much trouble.

sergio0592
Specialist III
Specialist III

Thanks for your video. But you're on Sense not VIew. But, both should have the same behaviour.

imsohotness
Contributor
Contributor
Author

Thanks for your suggestion. I will try this, but I am not sure how to go about it. Is it something that can be done from the sheet view or do I need to unlock the data load editor?

sergio0592
Specialist III
Specialist III

In your load statement, try with :

LOAD dual (Length, Num_lengt) as Length_of_service
INLINE [
Length, Num_lengt
More than 5 years,4
3-5 years,3
1-2 years,2
Less than 1 year,1
];
Claudiu_Anghelescu
Specialist
Specialist

=Match(only({1} [Item 3: Length of Service]),'More than 5 years','3-5 years','1-2 years','Less than 1 year')

To help community find solutions, please don't forget to mark as correct.