Sorting Stacked Bars in Tableau Based on User Selection
- Bernard Kilonzo

- Mar 31
- 2 min read

Overview
An effective way to make stacked bar charts feel more alive in Tableau is to let users directly influence how those bars are ordered, and set actions opens a particularly elegant path to that kind of interactivity. This article introduces the idea of using set actions not just for highlighting or filtering, but for dynamically sorting stacked bars based on whichever segment a user clicks. By capturing the selected segment in a set, translating that selection into a sort metric, and applying it to the bar order, you can create a chart that instantly reorganizes itself around the user’s curiosity.
Step-by-Step Guide
Using the Sample-Superstore data set, create a stacked bar chart.
Drag Sub-Category to the rows shelf.
Drag Sales to the columns shelf.
Drag Region to the color shelf to create the view below.

On the data pane, right-click on Region >> Create >> Set…
Configure your set as follows and create it.

Using the set above, create a new calculation for sorting the view.
See the calculation below.

(This calculation will be assigning the text “Aaaaaaaaa” on the selected Region therefore giving it precedence in our sorting order)
Next, sort the dimension Region added to the color shelf in descending order by “Region sorting calc” created above as shown below.

Next, add a set action and configure it as shown below.

This creates the visualization below which allows users to order the Region’s based on their selection.

Conclusion
Using set actions to sort stacked bars in Tableau offers a clean, intuitive way to let users drive the structure of the visualization without relying on parameters or extra controls. By capturing a user’s click, translating it into a dynamic sort rule, and applying that logic directly to the bar order, you create a chart that reorganizes itself in real time around what the user wants to explore. This approach not only enhances interactivity but also keeps the workflow lightweight and elegant, making it easier to maintain and scale across dashboards. Ultimately, set‑action‑driven sorting turns a familiar chart type into a more responsive analytical tool - one that invites curiosity, supports deeper comparisons, and helps users uncover insights that static sorting would never reveal.
If you like the work we do and would like to work with us, drop us an email on our contacts page and we’ll reach out!
Thank you for reading!!
