KNOWLEDGE BASE

Creating Dynamic "Others" Group based on User Selection


Published: 23 Sep 2015
Last Modified Date: 30 Aug 2023

Question

How to create dynamic groups based on the user selection.

For example, if the user selects sets a threshold sales amount in a parameter, than the all customers above that threshold should be shown by their names and all other customers should be grouped as "Others."

Environment

Tableau Desktop

Answer

The following instructions can be reviewed in the attached workbook, which can be found in the upper right hand corner of the webpage.
CLICK TO EXPAND STEPS
Option 1 - Create a calculated field
  1. Click the down arrow next to Dimensions in the data pane and select Create Parameter…
  2. In the Create Parameter dialog, do the following and click OK:
    1. Name the parameter. In this example, the parameter is named "Sales Threshold"
    2. For Data Type, choose Float
  3. Right-click [Sales Threshold] in the data pane and select Show Parameter Control
  4. Select Analysis > Create Calculated Field
  5. 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 "Customer or Others"
    2. In the formula field, create a calculation similar to the following:
      IF { Fixed [Customer Name] : SUM(Sales) } >= [Sales Threshold] 
      THEN [Customer Name] 
      ELSE "Others"
      END
  6. Drag [Customer or Others] to the Rows shelf
  7. Drag SUM(Sales) to Details
CLICK TO EXPAND STEPS
Option 2: Use Set Actions
This example will create a bar graph showing the total sales of user selected customers vs others. This uses the new Set Actions feature added in Tableau Desktop 2018.3

Step 1 - Create a Source sheet

This will be the sheet where the users will select customers from

  1. Drag [Customer Name] to the Rows shelf
  2. Drag [Sales] to the Columns shelf
  3. Drag a second copy of [Sales] to Label on the Marks card

Step 2 - Create the Target Sheet

  1. Right-click [Customer Name] in the data pane and select Create > Set…
  2.  In the Create Set dialog, do the following and click OK:
    1. Give the set a name. In this example, the set is named "Selected Customers"
    2. Make sure there is at least one checked and one unchecked customer
  3. Drag [Selected Customers] to the Rows shelf.
  4. Right-click the word "In" in the view and select Edit Alias.
  5. In the Edit Alias dialog, type something like "Selected Customers" and click OK.
  6. Repeat steps 4&5 for "Out" and rename it "Other customers".
  7. Drag [Sales] to the Columns shelf
  8. Drag a second copy of [Sales] to Label on the Marks card.

Step 3 - Create the Dashboard

  1. Create a new dashboard and add the source and target worksheets
  2. Navigate to Dashboard > Actions…
  3. In the Actions dialog, click Add Action > Change Set Values…
  4. In the Add Set Action dialog, do the following:
    1. For Source Sheets, check only Source Sheet
    2. For Run action on, choose Select
    3. For Target Set, in the first drop-down select the data source being used
    4. For Target Set, in the second drop-down select Selected Customers
    5. For Clearing the selection will, select Remove all values from set
  5. Click OK twice to close all dialogs.

Additional Information

To view the above steps in action, see the video below.
Note: the video has no sound. To view the video in higher quality, click the YouTube icon below to watch it on YouTube directly.


 
Did this article resolve the issue?