Responsive Stacked-Bar Charts in Tableau

In this tutorial, you'll learn how to create a responsive stacked-bar chart in Tableau that automatically sorts based on the selected item in the chart. This allows users to interact with the chart and bring any category to the front along the x-axis.


Step 1: Build the Stacked-Bar Chart

  1. Drag your time dimension (e.g., Order Date) to the Columns shelf and set it to Continuous Quarters.
  2. Drag your measure (e.g., Sales) to the Rows shelf as SUM(Sales).
  3. Drag your dimension (e.g., Category) to the Color mark.

You now have a basic stacked bar chart.

To convert it into a percentage view:

  • Right-click the SUM(Sales) pill, choose Add Table Calculation.
  • In the Table Calculation dialog, select Percent of Total and Table (down).

Step 2: Create a Parameter

  1. In the Data Pane, click the dropdown and select Create Parameter.
  2. Name the parameter (e.g., Response Parameter).
  3. Set Data Type to String.
  4. Set the Current Value to a default value from your dimension (e.g., "Furniture" from Category).

Step 3: Create a Calculated Field

  1. In the Data Pane, select Create Calculated Field.
  2. Name it something like Selected Response? (use ? to denote Boolean logic).
  3. Use this formula:[Category] = [Response Parameter]

Step 4: Create a Worksheet Action

Note: If you're working in a dashboard, go to Dashboard > Actions.
  1. Go to Worksheet > Actions.
  2. Click Add Action > Change Parameter.
  3. Name the action (e.g., Response Parameter Action).
  4. Set:
    • Source Sheets: the current worksheet.
    • Target Parameter: the one you created earlier.
    • Source Field: the dimension on Color (e.g., Category).

Step 5: Sort Based on the Selected Response

  1. Right-click the dimension on Color (e.g., Category) and select Sort.
  2. Set:
    • Sort By: Field
    • Sort Order: Ascending
    • Field Name: your calculated field (Selected Response?)
    • Aggregation: Minimum

Now, clicking a section of the bar chart will bring that value to the front on the x-axis.


Bonus: Prevent Unselected Items from Greying Out ("Dummy" Trick)

  1. Create a new calculated field named Dummy with the following formula:"dummy"
  2. Drag the Dummy field to the Detail mark.
  3. Create a Highlight Action:
    • Go to Worksheet > Actions > Add Action > Highlight.
    • Name it (e.g., Dummy Highlight).
    • Set both Source Sheets and Target Sheets to your current sheet.
    • Under Target Highlighting, choose Selected Fields and check Dummy.

This ensures that unselected parts of the chart don’t get dimmed when interacting with the chart.

Author:
Matthew Kelleher
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab