Using Sets in the Tableau Web App

Sets vs T|F Calculated fields

  1. Sets are similar to a True|False calculated field that identifies records that are IN vs OUT of the selected criteria. The same results can often be accomplished simply using T|F filter calculations.

  2. Some significant differences between T|F calculated fields and Sets are:

    1. With Sets, you can dynamically select which records are in or out of the Set. You can’t do that easily with a T|F Calculated field.

    2. Set logic processes before any dimension filters process, similar to FIXED LOD calculated fields, whereas T|F calculated fields process after dimension filters.

  3. Sets have even more functions available in the Tableau Desktop app, but they are still a useful tool in the Web App.

Sets vs Groups

Sets & Groups have similar characteristics in that they can be used to group records. Here are some of the differences:

  • Sets allow the Viewer to select which members belong in a set. To edit the members of a Group you must edit the workbook.

  • Groups can have different values within the one group.
    i.e., salespeople can be grouped into different territory names within the one Territory group. But a set only has two states of IN or OUT of the Set.
    To group salespeople into three Territory groups, you need to create a Set for each Territory.

  • In Groups, a record can only be a member of one group value.
    i.e., Salesperson1 cannot be a member of the Western Territory and the Eastern Territory groups.
    With Sets, you can make a record of multiple sets. Salesperson1 can be a member of the Western Territory Set and the Eastern Territory set. BUT…
    The salesperson will only display in the first Set, even though they are a member of other Sets. Tricky…

The most significant differentiator for Sets is the ability to dynamically select which records are in the Set.

Using Sets in the Tableau Web App

A common use of Sets is to dynamically select records to be in the Set so a record shows as IN or OUT.

Activity 3: Create a new worksheet with Customer Set, Customer and Sales.

Then use the Show Set Control to dynamically select which customers are IN or OUT of the Customer Set, showing subtotals for each set group.
See an example at 02 Sets: 01 Show Set Control - DataSelf Analytics

  1. The first step is to create a Set for the Customer field.
    Right click on the Customer field and select Create > Set.


  2. Once you have created a Set, there are three methods to select the records for your set.

    1. The Shortcut Menu has options to create a set, add to set, remove from set.
      Note: The shortcut menu is only available in Edit mode. Viewers don’t have access to this method.

    2. Right click on the Customer Set field and select the Show Set option to display the Customer selection list on the right. The Tableau help link is:
      Note1: The Set field needs to be on the worksheet in some manner in order to show it. You might mark it as a detail, color, tooltip, or part of a calculated field to have it on the worksheet.
      Note2: The Show Set function is available for viewers.

      You can also check Show Filter on the Set field to select records in the set or out of the set.
      DataSelf Example: Example 01 Show Set Control - DataSelf Analytics


    3. Worksheet Actions enable you to dynamically choose the members of a set by using a shortcut menu or clicking/highlighting rows.
      Tableau help link: Set Actions - Tableau
      DataSelf Example: Example 02 Worksheet Set Actions
      Note: Worksheet Action functions are available to viewers

      1. Create the Set. In this scenario we are using the Customer Set previously created.

      2. Click on the Worksheet Menu and select Actions topic.

      3. Add an Action to Change Set Values when selecting the Customer Set field on the worksheet.



3. In the example below, 02 Sets: 02 Worksheet Set Actions - DataSelf Analytics, the Customer Set
field is added to the Rows. The standard field label is IN/OUT(Customer). The customers are then sorted by sales in descending order (highest to lowest). Clicking on the first 5 customer records adds them to the IN group of the Set, based on the worksheet action settings. This shows the top 5 customers based on sales in the year. To clear the set selection, click twice on the IN label to first add all records then clear all records.

Select/Click action vs Menu action

The Select action is useful if you want to quickly select only one record and clear everything else.
The Menu action is useful if you want to select multiple records to add or remove from the set.
You can create two separate menu actions for each purpose, giving the viewer more control over actions.




Creating a calculated Set label instead of IN/OUT (of the Set).

The terms IN and OUT can be confusing. You can create a calculated field to provide more user-friendly category descriptions. In this example, we will call the group of customers IN the set Selected Customers. The rest of the customer records OUT of the set will be grouped as Other Customers.

  1. Create the calculated field and name it Customer Set Name
    If [Customer Set]Then 'Selected Customers' Else 'Other Customers' END

  2. Insert the Customer Set Name in front of the IN/OUT Customer field and verify it works as expected.
    In this example, change the Sort property of the Customer Set Name field to descending order so the Selected Customers group comes before the Other Customers group.

  3. Assuming the calculated field works as expected, remove the IN/OUT Customer field and verify the calculated field still works as expected. If it does not work, troubleshoot the calculation.

    Since the calculated Customer Set Name field refers to the Customer Set field, Tableau treats it as if the Customer Set field is on the active screen, because it is embedded in the calculation. So, you can still use the Show Set control even though the Customer Set itself is not displayed on the screen.

Territory Sets instead of Groups: Dynamic Sales territory groups that viewers can control.

02 Sets: Example 03 Sets as Territories - DataSelf Analytics

In a previous example we used Groups with Hierarchies to group salesperson records into sales territories. The problem with this method is that a view only user cannot modify the members of the territories on the fly. An explorer user would need to edit the workbook and change the salesperson records in each territory group, then save the workbook, which makes it a permanent change for everyone.

Sets allow the viewer to add/remove records in a set. This feature can be used to create a salesperson set for each territory, enabling the viewer to control which territory the salesperson is assigned to.

Activity: Create a Sales by Territory view using Sets instead of Groups.

  1. Create a new worksheet based on the Sales_Invoice data set.

  2. Create 3 Sets based on the Salesperson field and rename them for each Territory: (Western) Territory, (Central) Territory, (Eastern) Territory.

  3. Select Show Set for each of the sets so the viewer sees a selection list of salespeople for each territory.
    To do this, you will need to temporarily add the Territory fields to the Rows, so they are on the screen.
    The Show Set function allows the viewer to select the salespersons for each territory without needing to be an editor to modify the workbook.

  4. Create a calculated field to identify the territory name based on which set the salesperson is in. Name the calculated field Territory.
    If [(Western) Salesperson Territory Set] Then 'Western'
    Elseif [(Eastern) Salesperson Territory Set] Then 'Eastern'
    Elseif [(Central) Salesperson Territory Set]Then 'Central'
    Else 'Unkown'
    Once you add this calculated field to the Rows, you can remove the original Set fields from the Rows.
    The Show Set controls will still display since the Sets are embedded in the calculated Territory field.

  5. Set the sorting property as desired.
    Note: If you assign a Salesperson to multiple territory sets, the calculated Territory name will list the first condition that qualifies. It will not group the salesperson in multiple territories.

  6. You can create a hierarchy from Territory to Salesperson for drill down purposes.

Using Sets for selective drill-down

With the hierarchy drill-down function, when you expand a hierarchy, it expands for all rows, not just the row highlighted. But you can use Sets to create a drill-down feature that expands only the highlighted row.

DataSelf worksheet link: Example 04 Sets for Drilldown

In this example the Item Class field is displayed on the worksheet. The goal is to click on a specific Item Class and list all the items in that Class.

Activity: Create selective drill using sets.

  1. Create a new worksheet based on the Sales_Invoice data set.

  2. Create a Set for Item Class. Name the set Item Class Set. No Item Classes have been selected to be in the set yet.

  3. Add the Item Class Dimension to the Rows section of the worksheet.

  4. Create a Calculated field with the formula If [Item Class Set] Then [Item] Else '' END
    This formula states if an item is in the selected Item Class, then show the Item, otherwise display a blank.
    In this example the calculated field was named Item Class - Item.

  5. Add the Item Class-Item field to the rows section of the worksheet.

  6. Create a Worksheet/Action to Change Set Values for the Item Class Set.



7. When an Item Class is click/selected, it is added to the Item Class Set. Then the Item Class-Item calculated field displays all the Items in the set. This is because the calculated field makes the value in the Item Class - Item field all the same blank '' value if the Item Class is not in the Set. So the grouping feature of Tableau shows it as one row for the value. But if the Item Class has been added to the set, then the individual item values will display as separate rows. instead of the single blank '' value.

Example of selective drilldown for a Customer / Invoice / Items (multi-level)

Another case where the selective drilldown feature might be useful is when drilling down on Invoices to the Invoice lines. You might not want all the lines for all the invoices to show as separate rows, only the lines for the selected invoice.

  1. Create a new worksheet based on the Sales_Invoice data set.

  2. The first Dimension is Customer, create a set for Customer and name it Customer Set.

  3. Create a calculated field, If [Customer Set] Then [Inv No] Else '' END and name it Customer.Invoice.

  4. Create a Set of the Customer.Invoice field and name it Customer.Invoice Set .

  5. Create a 2nd calculated field Invoice.Item. If [Customer.Invoice]='' Then '' ElseIf [Customer.Invoice Set] THEN [Item] ELSE '' END

  6. Create Worksheet Actions for both sets to assign record and double click remove it.

Use Multiple Sets to identify records in all the sets.

02 Sets: 05 Dashboard Cust/Item Sets - DataSelf Analytics

  1. Create a worksheet with Customer Sales sorted in descending order so you see the top sellers at the top.
    02 Sets: 05a Customer Ranked Set - DataSelf Analytics

    1. Create a Customer Set & Worksheet action to add records to the set

  2. Create a 2nd worksheet with Item Sales sorted in descending order so you see the top sellers at the top.
    02 Sets: 05b Item Ranked Set - DataSelf Analytics

    1. Create an Item Set & Worksheet action to add records to the set

  3. Create a 3rd worksheet with In/Out Customer Set and In/Out Item Set

  4. Create a 4th worksheet with In/Out Item Set and In/Out Customer Set

  5. Show the Customer & Item Set filters and set them to only In

  6. Create a Dashboard showing all 4 worksheets
    02 Sets: 05 Dashboard Cust/Item Sets - DataSelf Analytics

  7. There is a Dashboards Actions section just like Worksheet Actions. Be sure to activate the Set Actions in the Dashboard as well. As you click on top Customers and Items to add them to their sets, the combined worksheet will show the records that meet both conditions.