6 Replies Latest reply: Jul 28, 2016 6:21 AM by Nicholas Truss

# Sort Stacked Bar Chart by Total

Hey guys,

Sorry if this has been answered before, I couldn't find the answer related to Qlik Sense.

I want to sort my stacked bar chart by total stakced and limit it to top 10 based on this total (I can only limit to top 10 based on the first meausre). All titles in the graph below are sorted from the same field of Title so I thought that by sorting by expression Count(Title) would work but it didn't.

My sort order is Active, Expired, Pending, Cancelled, [Dimension].

Thanks in advance if you guys can solve this issue!

• ###### Re: Sort Stacked Bar Chart by Total

Hi james,

try like this:

In sort tab of your chart, write this in expression:

sum(Active)+sum( Expired)+sum(Pending)+sum(Cancelled)

Keep the sort order ascending

Regards

KC

• ###### Re: Sort Stacked Bar Chart by Total

And for top 10 try like this:

In your dimension, create a custom dimension:

=if(aggr(rank(sum(Active)+sum( Expired)+sum(Pending)+sum(Cancelled)),Dimension)<=10,Dimension)

Regards

KC

• ###### Re: Sort Stacked Bar Chart by Total

That solves half my problem, thanks Jyothish!

My other problem now is that I want to limit this to the top 10, but when I limit to a fixed number of 10 it only shows the top 10 for the first measure (which is Active). Is there any way I can make the 'calculated by measure' to show the top 10 of total?

Edit: Sorry I replied after you posted. I'll try that out.

• ###### Re: Sort Stacked Bar Chart by Total

That's working awesome now thanks mate!

• ###### Re: Sort Stacked Bar Chart by Total

You are welcome

Regards

KC

• ###### Re: Sort Stacked Bar Chart by Total

Hi,

Understand this is a bit of an old post but didn't want to create a new one for a minor issue I am having with the above. I have tried using the following formula to order by stacked bar chart, however the order doesn't seem to have worked?

sum(AGED_CURRENT)+sum(AGED_30)+sum(AGED_60)+sum(AGED_90)+sum(AGED_OLDER)