Sorting stacked bar charts

by Saampave Sanmuhanathan

One of the limitations of using a stacked bar chart to visualise data is the difficulty to explore individual components due to categories being stacked on top of each other. By using set and parameter actions we can add an action so that by selecting on a category we reorder the stacked bar chart so that the category of choice would move it to the front. In this example we will be using sample superstore to create a stacked bar chart which has region then year of order date on rows and percentage of total sales on columns. which show the following:

1) Once you have created a stacked bar chart, create a string parameter which should look as follows:

2) We need to now create a Boolean calculation which gives true when the segment selected by the parameter is equal to the segment:

[Selected segment]= [segment Parameter]=[segment]

3) We then create a calculation which outputs [sales] when the [selected segment] calculation is true.

[Sort order]= If [selected segment] then [sales]

else 0

end.

4) We now now need to create a parameter action as follows:

We want the action to be triggered by selecting and for the current selection to remain the same when we deselect.

5) The final step is to add the sort order to segment. This can be done by right clicking segment then selecting sort. We then want to sort by the [sort order] calculation we created.

By following these steps you will be able to re-order your stacked bar chart.

Avatar

Saampave Sanmuhanathan

Tue 23 Apr 2024

Thu 28 Mar 2024