Mastering Dynamic Zone Visibility in Tableau
Suparna Chowdhury
Data Scientist | Python, SQL, and Tableau Expert | Driving Data Insights
What is Dynamic Zone Visibility?
Dynamic zone visibility is a powerful feature that can greatly enhance the interactivity and usability of your dashboards. It allows you to reveal or hide objects on a dashboard based on the value of a field or parameter. This feature can be applied to various elements such as worksheets, filters, legends, containers, or nested containers.
Requirements for Using Dynamic Zone Visibility
Supported Field Type
According to Tableau documentation, To utilize dynamic zone visibility, the trigger field or parameter must:
Tips
Use Case 1: Swapping Worksheets
We have three distinct sheets for different chart types:
Sheet 1 : Top 10 Sub-Category by Sales
Sheet 2: 2023 vs. 2024 Sales Performance
Sheet 3: Heatmap of Monthly Sales Across Years
Create the dashboard: Add all sheets to the same container on your dashboard.
Create a new parameter p.Chart Type that includes the names of the sheets you want to switch between.
2. Create Calculated field:
To enable Dynamic Zone Visibility, we need to create separate Boolean calculated fields for each of the three worksheets based on the selected parameter.
Top Subcats Visibility:
Create a calculated field named Top Subcats Visibility to determine if the Top 10 Sub-category by Sales sheet should be shown. This field will return True if the parameter [p.Chart Type] is set to 1, and False otherwise.
Create calculated fields for the other two charts in a similar fashion.
3. Configure Dynamic Zone Visibility:
Select the Top 10 Subcategory by Sales Sheet, go to the Layout pane, and check Control visibility using values. Choose Top Subcats Visibility.
As you configure Dynamic Zone Visibility, you may observe some charts disappearing. This is expected, as only one chart should be visible at a time based on the selected parameter.
Select the 2023 Vs 2024 Sales Performance Sheet, go to the Layout pane, and check Control visibility using values. Choose 2023 Vs 2024 Visibility.
Select the Heatmap of Monthly Sales Across Years Sheet, go to the Layout pane, and check Control visibility using values. Choose Heatmap Visibility.
Use Case 2: Worksheets with Filters Swapping
For this example, we have created four sheets for this scenario:
Sheet 1 — Combo: Displays a combined line and bar chart showing monthly sales and profit trends.
Sheet 2- Bar: Features a bar chart that categorizes sales by region and subcategory.
Sheet 3- Map: Includes a map illustrating sales across states and cities.
Sheet 4 — Menu:
o Prepare Helper File: Use an Excel file with two columns: “Id” (integer) and “Chart Type” (name of the chart or sheet).
o Import to Tableau: Bring this helper file into Tableau.
o Set Up the Sheet: Drag the “Chart Type” field to the Columns shelf and set the Marks type to “Shape.”
o Assign Icons: Place “Chart Type” on the Shape shelf and select appropriate icons for each chart type.
o Format and Rename: Adjust formatting as needed and rename this sheet as “Menu.”
Add Filters to Charts:
Create the dashboard:
o Add all charts (Bar, Line, Map) to a single container on your dashboard.
1. Create a Parameter:
Create a new parameter p.Swap Chart that includes the names of the sheets you want to switch between.
2. Create Calculated Fields:
To enable Dynamic Zone Visibility, we need to set up separate Boolean calculated fields for each chart type based on the selected parameter.
· Bar Visibility:
o Create a calculated field named “Bar Visibility” to determine if the ‘Bar’ chart should be shown. This field will return True if the parameter [p.Chart Type] is set to ‘Bar’, and False otherwise.
Create calculated fields for the other two charts in a similar fashion.
3. Apply the Visibility control:
Select the Bar Sheet, go to the Layout pane, and check Control visibility using values. Choose Bar Visibility.
Choose the Combo Sheet, navigate to the Layout pane, and enable Control visibility using values. Select Combo Visibility.
Finally, select the Map Sheet, check the “Control visibility using value” box in the Layout pane, and choose Map Visibility.
4. Add a parameter Action
Add a parameter action to update the parameter when clicking the icons on the Menu sheet. This will enable the chart displayed on the dashboard to change according to the selected icon.
Use Case 3: Show Detail
The primary function of this use case is to display the main chart on the dashboard. When a mark is selected on this main chart, a slide-out chart will appear, providing detailed information about the selected mark. If the selection is cleared, the slide-out chart will disappear.
领英推荐
Sheets Created:
Main Chart: Heatmap showing sales by region and category over 4 years.
Slide-out Chart: Sales trend by region.
Create the Dashboard Layout:
Add a horizontal container to your view. Inside this container, place two vertical containers. One for the Main Heatmap sheet and one for the Slide-out Chart.
The item hierarchy in the Layout pane will be structured as follows:
1. Create a Set
· Create a custom date.
· Create a Year Set- Based on the Year Custom Date field.
· Add the Year Set to the Detail shelf of the Main Heatmap sheet.
· Add Year to the Filter shelf and add Year to the Detail Marks of the Slide-out Line sheet.
2. Create Calculated Field:
Create a calculated field (Slide-out Visibility) with a Boolean value, using a fixed level of detail (LOD) calculation.
{MAX( {COUNTD(IF [Year Set] THEN [Year] END)} > 0 )}
3. Add dynamic zone visibility:
4. Create a Set action on the Dashboard
Use case 4: Zoom in / Zoom out
To achieve our goal, we’ll set up four separate sheets, each representing one of the following zones: Top Left, Top Right, Bottom Left, and Bottom Right. When the zoom-in icon is clicked for any zone (e.g., Top Left), the chart for that zone will be enlarged, while the charts for the other three zones will be hidden. Clicking the zoom-out icon will make all four charts visible again.
Dashboard:
2. To distinguish which zone is currently selected, you need to create four calculated fields. These fields will help identify if a particular zone is selected based on the parameter value.
Calculation for Top Left Zone: TL Selected Zone
“Top Left”
Calculation for Top Right Zone: TR Selected Zone
“Top Right”
Calculation for Bottom Left Zone: BL Selected Zone
“Bottom left”
Calculation for Bottom Right Zone: BR Selected Zone
“Bottom Right”
3. Create Calculated Field
TL Visibility
[p.Zoom ] IN (‘All’, ‘Top Left’)
TR Visibility
[p.Zoom ] IN (‘All’, ‘Top Right’)
BL Visibility
[p.Zoom ] IN (‘All’, ‘Bottom Left’)
BR Visibility
[p.Zoom ] IN (‘All’, ‘Bottom Right’)
Zoom Icon
[p.Zoom] != ‘All’
4. Set up Dynamic Zone Visibility
For each zone chart on the dashboard, select the chart, navigate to the Layout pane, check the Control visibility using values option, and then choose the corresponding Boolean calculated field from the dropdown menu.
Use Case 5: Show/Hide Sheet
This method of swapping sheets or charts is applicable when working with just two sheets.
In this example, the one sheet has a bar chart with Sales by Region, and the second sheet has a bar chart with Sales by Sub-Category. By using Dynamic Zone Visibility, the second sheet is visible only after a mark is clicked in the Sales by Region zone.
2. Create a calculated field- Dummy True.
3. On the Sales by Region sheet, drag the calculated field Dummy True to Details on the marks card.
4. Create a dashboard and arrange Sales by Region and Sales by Sub-Category sheets within the same container.
5. Use the Sales by Region sheet as a filter by clicking the dropdown arrow and selecting Use as Filter.
6. Create a parameter action.
7. In the Sales by Sub-Category zone, enable visibility control by checking Control visibility using value and choose the relevant parameter p.Show or Hide from the dropdown menu.
Use Case 6: Set up Map Drill down
Create two sheets: Profit by State and Profit by City.
Profit by State:
On a new sheet, double-click State/Province to generate a map of the United States. If the map doesn’t appear automatically, drag Country/Region to the Detail shelf to ensure the geographical map is displayed. Next, filter the map by dragging Country/Region to the Filter shelf and selecting United States. Adjust the mark type to Map to show a filled map. For color formatting, choose a Red-Black diverging color scheme and set the border color to white. Access the Background Layers in the Map menu and set the Washout to 100% for a clearer background. Rename the sheet to Profit by State.
Profit by City:
Duplicate the Profit by State sheet and rename the new sheet to Profit by City. Next, drag City onto the map, dropping it in the area labeled Add a Marks Layer. On the City marks card, switch the mark type to Circle. To provide additional context, add Country/Region and State/Province to the Detail shelf. Adjust the color of the circles to dark grey for better visibility.
Build a dashboard and arrange the Profit by State and Profit by City sheets within the same container.
2. Create a parameter p.state:
3. Define a calculated field named State Match with the formula [State/Province] = [p.State], and add this field to the filter shelf on the Profit by City sheet.
4. Define a Boolean calculated field named State Not Selected.
5. Enable the Control visibility using value option for the Profit by State sheet and select State Not Matched.
7. Add a parameter action to connect the Profit by State and Profit by City map interactions with dashboard parameter updates.
And that concludes our exploration of dynamic zone visibility use cases. I hope you found the information engaging and insightful!
I drew inspiration from Donabel Santos (sqlbelle) and Andy Kriebel’s insightful YouTube video, which significantly influenced the content of this article.
You can also dive deeper into the practical application of these techniques with the workbook linked below:
Thank you for reading, and happy dashboarding!