KNOWLEDGE BASE

How to Create a Viz to Flag Customers Who Have Purchased a Particular Item


Published: 22 Aug 2022
Last Modified Date: 22 Aug 2022

Question

How to flag what customer purchased a particular item in a Tableau visualization. 

Environment

  • Tableau Desktop

Answer

The following steps use the Superstore sample to flag customers who have purchased a particular subcategory and taking advantage of parameters.

1. Connect to Sample-Superstore.
2. Drag Customer Name to Rows.
3. Locate and right-click on the field Sub-Category in the Data pane to Create Parameter.  Select the following values and click OK.
User-added image
4. In the Parameters pane, right-click on Select Sub-Category and select Show Parameter.
5. Create a new calculated field as follows:
     Name : Purchase Flag
     Calculation : {FIXED [Customer Name] : MAX(
                          IF [Sub-Category] = [Select Sub-Category]
                          THEN "1"
                          ELSE "0"
                          END)}
6. Drag Purchase Flag to Rows.
User-added image

With the Parameter, Select Sub-Category set to Accessories, you will see the customers who have purchased Accessories are flagged as "1". 
Did this article resolve the issue?