9 Replies Latest reply: Apr 8, 2015 8:59 AM by Michael Solomovich

# 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

• ###### Re: Stacked Bar Chart Sorting based on values in charts

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

• ###### Re: Stacked Bar Chart Sorting based on values in charts

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

• ###### Re: Stacked Bar Chart Sorting based on values in charts

Not Cities...

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

• ###### Re: Stacked Bar Chart Sorting based on values in charts

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.

• ###### Re: Stacked Bar Chart Sorting based on values in charts

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).

• ###### Re: Stacked Bar Chart Sorting based on values in charts

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

• ###### Re: Stacked Bar Chart Sorting based on values in charts

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.

• ###### Re: Stacked Bar Chart Sorting based on values in charts

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.

• ###### Re: Stacked Bar Chart Sorting based on values in charts

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.