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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
CasperQlik
Creator
Creator

Issues with sorting

Hi Qlik Community

I have an unexpected issue with sorting a stacked by chart.

I want to sort my chart by the "bottom" category as seen below. However, it only sorts correctly when I select exactly 1 value in my year filter. Then it looks like the first image, sorted as expected. But if I select 2 or more or none, in the year filter, the sort will not behave like I expect. See the 2nd image. 

My measure is as follows: 

Sum(
{<
[category] = {"cat1", "cat2"}
>}
[values)
/
Sum( total <[dep_name]>
{<
[category] = {"cat1", "cat2"}
>}
[values])
 

My sort is as follows:

Sum(
{< 
[category] = {"cat2"}
>}
[values])
 
CasperQlik_1-1726562772643.png
 

CasperQlik_0-1726562730767.png

Any help is appreciated

3 Replies
hic
Former Employee
Former Employee

You need to have the same set expression in your measure and in your sort expression. Otherwise the sort expression will use other values than the ones you base your chart on.

CasperQlik
Creator
Creator
Author

I understand. But the crux of the issue is that I would like to sort on just the "size" of one of the categories like in the first image. My measure is a percentage distribution of the 2 measures combined. 

hic
Former Employee
Former Employee

It is difficult for me to see what happens since I don't have the data, but...
it looks as if the first 9 bars are correctly sorted, and the only one wrong is the last one. Probably since the sort expression for this bar evaluates to NULL. Could it be that the last bar is excluded by the set expression in the sort? E.g. if there are no 'cat2' here?

Bottom line is in any case that you need to decide how to sort the bars that are excluded by the set expression in the sort. (My guess: [dep_name] that have 'cat1' but not 'cat2').