Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
arixooo123
Creator III
Creator III

Stacked Bar Chart Sorting based on values in charts

Dears!

Please take a look at the attached image chart, as you can see my stacked bar chart can get sorted by 2 different dimensions. one dimension controls the order of values shown in each stack, the other control the order of stacks appeared in chart. 

I would like to sort the stacks based on the blue value decreasingly.

It has to come in the expression part of sorting. bu i don't know the appropriate script for that. 

BR

Arman

1 Solution

Accepted Solutions
Anonymous
Not applicable

You thought right.

Example 1:

Your expression in the expression tab is sum(Sales).  In this case your expression in sort tab is

sum ({$<Status= {ExCustomer} >} Sales).

Example 2:

Your expression in the expression tab is count (distinct Apples).  In this case your expression in sort tab is

count ({$<Status= {ExCustomer} >} distinct Apples).

View solution in original post

9 Replies
Roop
Specialist
Specialist

In the sort use the expression sum( {$<Grouping= {ExCustomer} >} Sales ) where Grouping is your dimension ....



arixooo123
Creator III
Creator III
Author

Name of Dimension including "ExCustomer" is Status, the Other Dimension is Cities.

so you are saying it should be like this:

sum( {$<Status= {ExCustomer} >} Cities )

?

it doesn't work

Anonymous
Not applicable

Not Cities...

The expression is the same you use in your chart, but with additional set condition {$<Status= {ExCustomer} >}

arixooo123
Creator III
Creator III
Author

Dear,

You mean in the expression tab?

I thought there should be a way to add an expression in sort tab to sort stacks based on a value.

sorry if i didn't get what you say.

Anonymous
Not applicable

You thought right.

Example 1:

Your expression in the expression tab is sum(Sales).  In this case your expression in sort tab is

sum ({$<Status= {ExCustomer} >} Sales).

Example 2:

Your expression in the expression tab is count (distinct Apples).  In this case your expression in sort tab is

count ({$<Status= {ExCustomer} >} distinct Apples).

arixooo123
Creator III
Creator III
Author

I'm sorry but i dont want to have just ExCustomer values being shown in the

charts. I would like to have all of them but sort the cities based on their

ExCustomer percentage.

For example city A which has the largest ExCustomer share should come first

in the chart.

I hope i could deliver my message

Thanks for your help

Anonymous
Not applicable

You succeeded delivering your message but oyu failed to recognize mine

Trying last time...

Chart expression in "example 1" is sum(Sales).  That means that all Status values are included.

Sort expression is sum ({$<Status= {ExCustomer} >} Sales).  That means that sort will be using only Status 'ExCustomer'.

If you upload a sample of your application, I (or someone else) can show you.

arixooo123
Creator III
Creator III
Author

I know your answer is correct, but i still cannot manage it to work.

my chart expression is :

count(DISTINCT SUB_ID) / count(total <CITY> DISTINCT SUB_ID)

In Sort Expression i tried :

Count( {$<CustomerStatus= {'ExCustomer'} >} SUB_ID )

Real Question :

Sort the cities in charts order by the biggest ExCustomer Values in stacked bar charts.

Anonymous
Not applicable

My best guess is that the Sort expression should be this:

count({$<CustomerStatus= {'ExCustomer'} >} DISTINCT SUB_ID) / count({$<CustomerStatus= {'ExCustomer'} >} total <CITY> DISTINCT SUB_ID)

But there is always a chance that you've missed something.  It would be so much easier to help you if you could upload an example of your application.