3 Way Venn in Tableau Upgrade

IT

3 Way Venn in Tableau Upgrade

by Rob Austin

This post is an upgrade to my original 3 Way Venn post, or at least is a better alternative as it gives the right numbers loads faster and is easier to make!

This method doesn’t use sets or anything complicated within Tableau but rather it uses a self join on the data tables. I am using the demo dataset ‘Sample – Superstore Sales (Excel)’ which ships with tableau desktop.

 Screen Shot 2014-10-13 at 15.08.14

The Orders table has been joined to itself on ‘Customer Name’ twice. This gives the ability to easily compare table entries on a single row rather than needing to reference other rows using a table calculation or set. This type of self join can be used for cohort or market basket analysis as well.


I have also created an extract and filtered it to keep only Jumbo Box, Jumbo Drum and Large Box.

I have done this on each of the ‘Orders’ tables as shown:

Screen Shot 2014-10-29 at 16.48.24     Screen Shot 2014-10-29 at 16.48.00


The only fields which I need to keep are: Customer Name, Product Container (Orders$), Product Container (Orders$1) and Product Container (Orders$2). The rest can be hidden for now then removed when we re-create the extract.

 Screen Shot 2014-10-13 at 15.23.26


  We now need to break our customers in to 3 groups & because of the data structure we are able to do this in a single calculated field:

Screen Shot 2014-10-13 at 15.39.16

Copy & Paste if you prefer:

//Customers who used 3 Shipping Methods
 if [Product Container]>[Product Container (Orders$1)] AND [Product Container (Orders$1)]> [Product Container (Orders$2)] then [Product Container]+ ‘ – ‘ + [Product Container (Orders$1)] + ‘ – ‘ + [Product Container (Orders$2)] elseif [Product Container]<[Product Container (Orders$1)] AND [Product Container (Orders$1)]< [Product Container (Orders$2)] then [Product Container (Orders$2)]+ ' - ' + [Product Container (Orders$1)] + ' - ' + [Product Container]
//Customers who used 2 Shipping Methods
elseif [Product Container]<[Product Container (Orders$1)] then [Product Container]+ ' - ' +[Product Container (Orders$1)] elseif [Product Container]>[Product Container (Orders$1)] then [Product Container (Orders$1)] + ‘ – ‘ +[Product Container]
//Customers who used 1 Shipping Method
else[Product Container] end

When we now do a distinct count of the customer names, the customers who used 3 shipping methods will also appear in the other 2 groups.  The customers who used 2 shipping methods will also appear in the singles group.

Here are the other calculated fields I have used in the Dashboard:

Field Name Calculation Default Direction
Index()
INDEX()
Computed along [Containers Match 3], [Product Container]
Front / Back
IF [Index()]<=3 THEN 'Front' ELSE 'Back' END
N/A
Containers Match Length
LEN([Containers Match 3])
N/A
Label
IF [Front / Back] = ‘Front’
THEN ATTR([Product Container])
ELSE ‘ ‘ END
N/A
Size
IF [Front / Back] = ‘Front’ THEN COUNTD([Customer Name]) else 0 end
N/A
X3a
CASE [Index()] WHEN 1 THEN 1 WHEN 2 THEN 2 WHEN 3 THEN 1.5 WHEN 4 THEN 1.5 WHEN 5 THEN 1.5 – 0.44*[Label Position] WHEN 6 THEN 1.5 + 0.44*[Label Position] ELSE 1.5 END
Table Across
Y3a CASE [Index()] WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 3 THEN 2 WHEN 4 THEN 1 WHEN 5 THEN 2-0.89*[Label Position] WHEN 6 THEN 2-0.89*[Label Position] ELSE 2-[Label Position] END Table Across

  [Label Position] is a parameter between 0 & 2 which allows us to position the labels on the inside of the top venn bubble.


Once all these fields have been created, arrange them on your worksheet as shown below:

Screen Shot 2014-10-13 at 16.11.16

Note that all of the Table Calculations (the fields with the triangle next to them) should be correct if the [Index()] defaults have been set up correctly:

Screen Shot 2014-10-13 at 16.16.17 

The [Containers Match 3] field should be sorted ‘ascending’ based on MIN([Containers Match Length])

Screen Shot 2014-10-13 at 16.19.50


Finally, adjust the marks. Make sure that you can see all of your mark labels by allowing them to overlap and position them ‘middle centre’.

You will need to add some transparency (click ‘color’) and make sure that the sizing is dialled right up (click ‘size’).

Screen Shot 2014-10-29 at 17.29.51

If all goes well you now have yourself a 3 way Venn Diagram. You can adjust the position of the labels using the parameter once you have brought the worksheet in to a dashboard.  You will need to make sure that the dashboard size is fixed and spend a little bit of time getting the sizing right.

If your data is likely to change wildly you may need to keep an eye on the sizing to make sure that the labels stay within their boundaries.

Happy venn-ing!  

More About the Author

Rob Austin

Consultant
Using Tableau on your Mobile I have been using Tableau since version 4, initially as a Tableau customer. One of the first things I wanted was to be able to see my ...
Tableau Level of Detail Calculated Fields v9 In this tutorial I talk about the Tableau Level of Detail calculations  {fixed}, {include} and {exclude} which are new in Tableau ...

See more from this author →

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK