Hi everyone! I accepted a challenge from my dear friend “Jude Shu” to build a dynamic stacked bar chart by using sets. Jude already showed how to build a Stacked bar sort using Sets. If you like to use stack bar charts, I ensure you that you will love our blogs.

Blog: Level up your stacked bar charts with Sets! Click Here!

Here are steps to create drill-down dashboards by using parameters. Setting up this interaction in the dashboard to make your dashboard neat and easier to drill down from the high level.

The example workbook link. Dynamic Stacked Bar Charts | Tableau Public

For the dataset, I use the Sample Store dataset.

Step 1: Start with building a stack bar chart.

  • Bring Order Date by Month to the Columns shelf.
  • Bring SUM(Sales) to the Rows shelf.
  • On the Marks Shelf, I put a sub-Category field in the Color.
  • Also, I will select only Technology category.

Step 2: Create a Parameter for Sub-Category. We will set a parameter action base on this parameter. I will call this parameter “1. Parameter Sub-Category”

  • Select Data Type by “String”.
  • Select Allowable values by “List”.
  • Add the Sub-category value to the list. Also, Add “All” in the value.

Step 3: Create a calculation field to bring parameters to life. Parameters will not do anything until we create calculations to bring parameters to life.

Calculation “2. SortSub-Category”

This calculation will show the value per selected value from the parameter. I use the CASE function. You can find more information about the calculation function from the window beside the calculation function.

Here is the formula;
CASE [1. Parameter Sub-Category ]
WHEN “Copiers” THEN “Copiers”
WHEN “Accessories” THEN “Accessories”
WHEN “Machines” THEN “Machines”
WHEN “Phones” THEN “Phones”
WHEN “All” THEN [Sub-Category]
END

Calculation “3. SelectSub-Category”

The value from this calculation is True or False. After we create this calculation, bring the calculation to Filters Shelf and Select “True”.

Here is the formula; [Sub-Category] = [2. SortSub-Category]

Step 4: Set the parameter action in the sheet.

  • Go to “Worksheet” then select “Actions”. This will bring up the Actions window.
  • Click on the “Add Action” drop-down menu and select “Change Parameter”.
  • I name this Change Parameter action “4. Parameter Sub-Category”.
    • Select Source Sheets “Sheet 1” (the bar chart sheet name)
    • Select Run action on “Select”
    • Select Target Parameter 1. Parameter Sub-Category. (The parameter which we created)
    • Source Field, select “Sub-Category” field.
    • Aggregation, select “None”
    • Clearing the selection will “Set value to” and type in “All”

Note: Check the action after configuring the action. (Please note that the action is created on the sheet, you might need to replicate the action on the dashboard page)

Step 5: Configure to show the number of total sales when drilling down by using Highlight action. (The example per the below chart)

  • Go to “Worksheet” then select “Actions”. This will bring up the Actions window.
  • Click on the “Add Action” drop-down menu and select “Highlight”.
  • I name this Change Parameter action as “5. Assign Sales value”.
    • Source Sheets, I selected the stack bar chart sheet which is “Sheet 1”.
    • Target Sheets, I selected the stack bar chart sheet which is “Sheet 1”.
    • Target Highlighting, I selected “Selected Fields” and ticked on “Sub-Category” Field.

Step 6: Showing the total sales by duplicating the bar chart. Under the new Marks section on the duplicate chart removed “Sub-Category” from the color and added “SUM(Sales)” on the label.

  • In the new duplication chart label, checked Show mark labels.
  • Select “Gantt Bar” from the drop-down menu.
  • In the “Color”, selected the Opacity at 0%.

 

That’s all for today! See you next time!

 

The Data School
Author: The Data School