Current location - Recipe Complete Network - Diet recipes - Give me a chestnut! Tableau Tips (59): Learn to make a Venn diagram of two sets (Venn diagram)
Give me a chestnut! Tableau Tips (59): Learn to make a Venn diagram of two sets (Venn diagram)

The scientific name of the Venn diagram we often call is: Venn diagram, also known as the Venn diagram. This kind of diagram is mainly used to show mathematical or logical connections between different groups (sets) of things.

Basketball-loving data fans may have seen such a Viz. The author analyzes the matching effect of each team's player lineup this season. Using a Venn diagram, we can intuitively see the performance of two players with different abilities when combined together.

In Tableau, Venn diagrams are often used to show overlapping or unique parts of multiple data sets.

The intersection of two data sets is called a Venn diagram of two sets. Of course, Venn diagrams of three, four or even five or six sets can be applied as long as the visualization is good.

Today, let’s start with the simplest one and learn how to implement a Venn diagram of two sets in Tableau!

In this issue of "Give a Chestnut", the Tableau skill Ada wants to share with you is: learn to make a Venn diagram (Venn diagram) of two sets.

To facilitate learning, Lizi uses the "Example-Supermarket" data source that comes with Tableau. After mastering the chestnut method, data fans can try using their own data sources.

————————————————————————————————》》

The specific steps are as follows:

1. Create a set

Open Tableau Desktop, connect to the "Example-Supermarket" data source, and create a new worksheet. First, three sets need to be created.

In the "Data" pane, right-click "Category" and select "Create" - "Set" from the drop-down menu.

In the pop-up dialog box, name the set: Office Supplies, and check: Office Supplies.

?Follow the same steps and create another set: Technology.

Right-click "Customer Name" and select "Create" - "Set". In the pop-up dialog box, name the set: Office Supplies and Technology.

Then, enter the "Conditions" tab, select: By formula, and enter in the formula bar (the formula is not case-sensitive):

SUM(IF [category]=" Office supplies" then 1 end)>0

and

SUM(IF[category]="Technology" then 1 end)>0

2. Create Calculated fields

Click the triangle button on the right side of the "Data" pane and select from the drop-down menu: Create calculated fields. Three calculated fields need to be created.

? To create a calculated field: External Venn diagram position, type function:

COUNTD(IF [Office Supplies] then [Customer Name] END)

? Create a calculated field: Overlap location, type function:

[External Venn diagram location]/2

? Create a calculated field: Number of Office Supplies and Technology Customers, type function:

p>

COUNTD(IF [Office Supplies and Technology] = TRUE THEN [Customer Name] END)

3. Create a view

Double-click the blank space of the row and type: AVG (0).

Drag and drop the calculated fields "External Venn Position" and "Overlap Position" to the column in turn, right-click the "Overlap Position" capsule on the column, and select: Dual Axis in the drop-down menu.

Right-click the "Overlap Position" axis in the view and select: Edit Axis in the drop-down menu. In the pop-up dialog box, uncheck: Include zeros.

Drag and drop "Category" into the color of the "All" "Tag" card.

In the color legend, Ctrl-click Office Supplies and Technology, and select Keep Only.

Drag and drop the dimension "Customer Name" to the size of the "All" "Marks" card, then right-click the capsule and select: Measure - Count (Different) in the drop-down menu.

Drag and drop the dimension "Customer Name" to the label of the "All" "Marks" card, then right-click the capsule and select: Measure - Count (Different) in the drop-down menu.

On the Overlap Position Marks card, change the Mark Type to: Text.

Change the "Category" capsule, "Count (Different) Customer Name" capsule, and "Count (Different) Customer Name" capsule on the "Overlap Position" "Mark" card from the color, size, and text respectively. Remove.

Drag and drop "Office Supplies and Technology Customers" into the "External Venn Diagram Locations" tab of the "Mark Card". Change the Marker Type to: Circle, change the Color Transparency to: 75%, and add a border.

Increased the size of the "External Venn Diagram Location" "Mark" card to the maximum value.

Tips: The overlapping position of the two circles can be adjusted as needed by editing the "External Venn Diagram Position" axis.

Right-click on the capsules on the columns and rows respectively and uncheck Show Titles in the drop-down menu.

Click "Format" - "Line" in the top menu bar. In the "Line" tab of "Format Line", set the grid lines and zero value lines to: None. Then switch to the "Border" tab and set the row separator and column separator to: None.

In this way, the Venn diagram of the two sets we want is completed.

Have you got today’s Tableau tips? Hurry up and give it a try!