KNOWLEDGE BASE

Limiting Actions to Specified Marks or Headers in a View


Published: 24 Oct 2013
Last Modified Date: 17 Oct 2018

Issue

How to limit an Action to trigger only when certain specified marks or headers are selected or hovered over.

For example, when selecting California the filter action should show a sales area chart, but the dashboard should show a profit line chart.

Environment

  • Tableau Desktop
  • Filter Actions, URL Actions, or Highlight Actions

Resolution

Both examples are demonstrated in the attached workbook, which can be downloaded from the right-hand side bar of this article. Example 1 shows how to limit Actions based on the value of the dimension selected. Example 2 shows how to limit Actions based on which dimension the user selected. Option 1 for both examples will allow for the creation of two separate Actions, and will work for Filter Actions, URL Actions, and Highlight Actions. Option 2 for both examples creates a Filter Action that will conditionally show a different target worksheet.
 
CLICK TO EXPAND STEPS
Example 1: Limit Actions based on the selected dimension value
Instructions for both options start with the "Example 1: Original Dashboard" dashboard already created. In this example, the goal is to show a different graph when the user selects California versus other states.

Option 1: Create a Calculated Field that will return non-NULL values for only certain marks

This option will work when different marks created by different members of the same dimension. This option will only work when Actions are triggered by Menu rather than Select or Hover.
  1. Select Analysis > Create Calculated Field
  2. In the Calculated Field dialog box that opens, do the following, and then click OK:
    1. Name the calculated field. In this example, the calculated field is named "Menu Link CA"
    2. In the formula field, create a calculation similar to the following:
      IF [State or Province] = "California"
      THEN "Click to see CA Graph >"
      ELSE NULL
      END
      
  3. Create a calculated field with a name like "Menu Link All Other States" with a calculation similar to the following:
    IF [State or Province] != "California"
    THEN "Click to see All Other States Graph >"
    ELSE NULL
    END
    
  4. Drag [Menu Link CA] and [Menu Link All Other States] on the Marks card on the "Final Map" worksheet
  5. Navigate to the "Opt 1 Final Dashboard" dashboard
  6. Navigate to Dashboard > Actions...
  7. In the Actions dialog, select Add Action > Filter...
  8. In the Add Filter Action dialog, do the following, and click OK:
    1. For Name, click the arrow next to the text box and select Menu Link CA
    2. For Source Sheets, check only Final Map
    3. For Run action on, select Menu
    4. For Target Sheets, check only CA Graph
    5. For Clearing the selection will, select Exclude all values

      Note: Step 8-1 is setting the name of the Filter Action to the output of the calculated field [Menu Link CA]. When this calculated field returns NULL then the Filter Action menu link will not appear in the tooltip.
  9. Repeat step 8 to create a Filter Action to filter the "All Other States Graph" worksheet
  10. Click OK to close the Actions dialog.

Option 2: Duplicate the filter field to set up competing filters on the target worksheets

This option will work when different marks created by different members of the same dimension. This option will only work for Filter Actions.
  1. Right-click [State or Province] in the data pane and select Duplicate
  2. On the "CA Graph" worksheet, drag [State or Province (copy)] to the Filters shelf
  3. In the Filters dialog, check only California, and click OK
  4. On the "All Other States Graph" worksheet, drag [State or Province (copy)] to the Filters shelf
  5. In the Filters dialog, check all states except for California, and click OK
  6. On the dashboard, navigate to Dashboard > Actions...
  7. In the Actions dialog, select Add Action > Filter...
  8. In the Add Filter Action dialog, do the following, and click OK:
    1. For Source Sheets, check only Final Map
    2. For Run action on, choose Select
    3. For Target Sheets, check CA Graph and All Other States Graph
    4. For Clearing the selection will, select Exclude all values
  9. Click OK to close the Actions dialog
CLICK TO EXPAND STEPS
Example 2: Limit Actions based on which dimension was selected
Instructions for both options start with the "Example 2: Original Dashboard" dashboard already created. In this example, the goal is to show a different graph when the user selects a category value,versus a sub-category value. 

Option 1: Create Multiple Worksheets Each with their Own Action

This option will work for URL Actions, Highlight Actions, or Filter Actions.  

  1. Right-click the tab for the "Category or Sub-Category Source" worksheet and select Duplicate
  2. Give the new worksheet a name like "Category Source"
  3. Remove [Sales] from the Columns shelf
  4. Right-click [Product Sub-Category] on the Rows shelf and uncheck Show Header
  5. In the dropdown menu on the Marks card, select Polygon
  6. Navigate to Format > Borders…
  7. In the Format Borders left-hand pane, for Column Divider, for Pane, select None
  8. Repeat steps 1-7 for any columns that will need their own Filter Action
  9. Right-click the tab for the "Category or Sub-Category Source" worksheet and select Duplicate
  10. Give the new worksheet a name like "Bar Chart"
  11. Right-click each dimension on the Rows shelf and uncheck Show header
  12. On the dashboard, replace the "Category or Sub-Category Source" worksheet with the "Category Source", "Sub-Category Source", and "Bar Chart" worksheets

    Note: Tableau Desktop 10.4 introduced padding on dashboard objects, which may help with achieving perfect alignment of the three worksheets
  13. Navigate to Dashboard > Actions...
  14. In the Actions dialog, select Add Action > Filter...
  15. In the Add Filter Action dialog, do the following, and click OK:
    1. For Source Sheets, check only Category Source
    2. For Run action on, choose Select
    3. For Target Sheets, check only Category Details
    4. For Clearing the selection will, select Exclude all values
  16. Repeat steps 13-15 for any additional Filter Actions

Option 2: Create a Calculated Field that compare the number of selected marks to the total number of marks   

This option will work when different marks or headers are created by dimensions. This option will only work when Actions are triggered by Menu rather than Select or Hover.
  1. Select Analysis > Create Calculated Field
  2. In the Calculated Field dialog box that opens, do the following, and then click OK:
    1. Name the calculated field. In this example, the calculated field is named "Some or All Subcategories Selected"
    2. In the formula field, create a calculation similar to the following:
      IF TOTAL(COUNTD([Product Sub-Category])) =
      SUM({ FIXED [Product Category] : COUNTD([Product Sub-Category])})
      THEN "all"
      ELSE "some"
      END
      
  3. On the "Category Details" worksheet, drag [Some or All Subcategories Selected] to the Filters shelf, and click OK to close the Filter dialog
  4. Right-click [Some or All Subcategories Selected] on the Filters shelf and select Compute Using > Table (down)
  5. In the Filter dialog, do the following and click OK
    1. Select Custom value list
    2. Type in "all" without quotes
    3. Click the + symbol in the text box
  6. Repeat steps 2-4 for the "Sub-Category Details" worksheet
  7. On the dashboard, navigate to Dashboard > Actions...
  8. In the Actions dialog, select Add Action > Filter...
  9. In the Add Filter Action dialog, do the following, and click OK:
    1. For Source Sheets, check only Source Sheet
    2. For Run action on, choose Select
    3. For Target Sheets, check Category Details and Sub-Category Details
    4. For Clearing the selection will, select Exclude all values

Cause

The ability to limit action filters to only execute on some marks within a view is not functionality currently built into the product.
Did this article resolve the issue?