Last Modified Date: 14 Apr 2022
Environment
- Tableau Desktop
Answer
Step 1 Create a Set to group customers who purchased product A1. Right click on [Customer ID] in the data pane and click [Create]>[Set]
2. In the Create Set dialog, do the following and click OK
a. Name the set [Customers who purchased A]
b. Select [Condition] tab and put in the following formula into [By formula]
b. Select [Condition] tab and put in the following formula into [By formula]
COUNT(IF [Product]="A" AND [Sales]="Y" THEN [Customer ID] END)>0
Step 2 Create a Set to group customers who purchased product B
1. Right click on [Customer ID] in the data pane and click [Create]>[Set]
2. In the Create Set dialog, do the following and click OK
a. Name the set [Customers who purchased B]
b. Select [Condition] tab and put in the following formula into [By formula]
b. Select [Condition] tab and put in the following formula into [By formula]
COUNT(IF [Product]="B" AND [Sales]="Y" THEN [Customer ID] END)>0
Step 3 Create a Combined Set to group customers who purchased both product A and product B
1. Multi-select [Customers who purchased A] and [Customers who purchased B] in the data pane and right click on them > click [Create combined set]
2. In the Create Set dialog, do the following and click OK
a. Name the set [Customers who purchased A and B (Set)]
b. From the list, select [Shared members in both sets]
b. From the list, select [Shared members in both sets]
※- [Create Combined Sets]
Step 4 Display the number of customers who purchased both A and B on the view
1. Click the down arrow next to Dimensions in the data pane and select Create Calculation Field…
2. In the Calculation dialog, put in the following formula and click OK
Step 4 Display the number of customers who purchased both A and B on the view
1. Click the down arrow next to Dimensions in the data pane and select Create Calculation Field…
2. In the Calculation dialog, put in the following formula and click OK
a. Name the calculation field [Customer who purchased both A and B ?]
b. put in the following formula
IF [Customers who purchased A and B (Set)] THEN "Yes"
ELSE "No"
END
b. put in the following formula
IF [Customers who purchased A and B (Set)] THEN "Yes"
ELSE "No"
END
3. Drag calculation field [Customer who purchased both A and B ?] to Row shelf
4. Click the down arrow next to Dimensions in the data pane and select Create Calculation Field…
5. In the Calculation dialog, put in the following formula and click OK
4. Click the down arrow next to Dimensions in the data pane and select Create Calculation Field…
5. In the Calculation dialog, put in the following formula and click OK
a. Name the calculation field [#CutomerID]
b. put in the following formula
COUNTD([Customer ID])
b. put in the following formula
COUNTD([Customer ID])
6. Drag calculation field [#CutomerID] to [Text] Marks card.
Please refer to "Sample.twbx" attached for more details.
Please refer to "Sample.twbx" attached for more details.
Thank you for providing your feedback on the effectiveness of the article.
Open new Case
Continue Searching
Knowledge Base
Community
Product Help
Training and Tutorials