When I create a stacked bar chart (and, honestly, that is just about the only chart type I create), I want the ability to sort the series values automatically.
Today, I can navigate into the Series tab and manually reorder. But this becomes very annoying when there are a lot of values or when the series is constantly moving.

For example, here:


it would be great to be able to automatically sort the bars by the values of series in ascending or descending order. It could pick the first or last column as the bar from which to sort, and the remaining columns would follow that sort order. So in this case if I picked “Sort by rightmost column descending”, I would see the largest series at the bottom (681, green), followed by the next largest (682, purple), and so on.

2 Likes

It’s 2019, still couldn’t find this nice feature

It’s 2020 now and still no solution?

I just added a reference to this in our Chart Visualization documentation.

You can use the Series tab of the Visualization Editor to control the order in which traces are stacked. You can also control it by adding an ORDER BY statement to your query. The stack follows the order in which your group names first appear in your query result.

In the following examples, notice that the same measures remain the same color but they stack in different orders.

Ascending

Groups are sorted alphabetically ascending

Descending

Groups are sorted alphabetically descending

Arbitrary Order using CTE

Groups are sorted arbitrarily

This has been true since 2017. The question just didn’t receive much attention on the forum. If you have other questions don’t hesitate to bump them :smiley:

I think what is being asked here is to sort the bars based on the value not based on the group.

The idea being that when you look at the stacked bar chart (or area chart) your larger values appear at the top and your smaller values appear at the bottom (or reverse of this).

I’m not so sure. Look at this:

For scenario X, red is always smaller than green which is always smaller than blue. For scenario Y, each color takes a turn being largest.

Projection A and Projection B both automatically stack colors from largest to smallest like you described. Projection C uses the same data as B but the stack order is manual/frozen: green, blue, red.

Automatic sorting makes sense in scenario X. But it’s unnecessary because the same outcome is possible with an ORDER BY statement.

In scenario Y, automatic sorting is harder to read than manual. Plotly doesn’t support it. Neither does Redash. Anecdotally, I don’t know a tool that does support it which is why I had to draw these illustrations by hand.

I read OP’s question as how to arrange the stack order without using the Series tab. The alternative is not desirable as far as I can tell.

Projection C is exactly what I would want.
In the consulting firm I used to work in, we worked with stacked bar charts extensively, and this question was “settled” with the answer being Projection C.
Most users are focused on the last column (most recent, if time is on the Y column), so, that should be the one to drive the sort order, and all columns to the left of it should follow behind.

Hi @jesse , I am not sure whether this’ been asked before or not. But I’m stuck on how to make a clustered stacked bar chart on Redash. The chart that I mean looks like in the below image (also in the image is the format of data on how to make clustered stacked bar chart on google sheets and ms. excel)

And then, I just saw this thread here that you show how to make a chart like this

Which pretty much look like the clustered stacked bar chart that I am trying to make.

Can you please show me how is the format of the data on how you make that?