I recently built this viz from a makeover Monday dataset of Dark Web product prices. This creation used a few interesting Tableau techniques, so I wanted to share some insights from the creation of this chart.

Essentially, I created two rings – an outer ring for category, and an inner ring for product. Selecting a category will reveal the inner ring of its products. Watch this below!

For this blog I will be reconstructing a similar viz based on Tableau’s Superstore data. Follow along to build out this visualisation with me.

Drawing circles using polar coordinates

My recent obsession in Tableau has been drawing circles. The maths involved is simple and elegant and takes advantage of Tableau functionality to do something creative. Here’s how to do it.

First you want to create an index for whatever dimension you want to make up the points on your circle. Normally, I would use the INDEX() function. However, in this case I plan on using INDEX() later for another purpose, so it is easier for me to do it manually with a CASE statement. This is shown below (this is a tedious calculation so I will include it at the end of the blog if you want to copy and paste it).

Then, using this field, I create an angle – think of this as each point’s angle from the centre of the circle (a bit like numbers on a clock). This is calculated as follows.

Here, I divide by 17 because that’s the total number of Sub-Categories (it might be better practice to divide by COUNTD(Sub-Category) instead). Then I multiply by 2 pi to convert to radians. I also create a parameter called [outer radius], of type float and equal to one, which describes the radius of this circle. Now we have everything we need to start drawing circles.

This next step is where we must use some trigonometry. The previous step has information of the angle of each Sub-Category point along the circle, and its distance from the centre. This information is in the form of polar coordinates, but Tableau processes Cartesian coordinates. That is, we need to change the information from (angle, radius) to (X, Y) form. The following formulas use trigonometry to make these conversions.

After creating these calculations, simply drag X and Y to your columns and rows respectively and convert them to dimensions. You should have a view that looks like the following (I have put Sub-Category as a label to show how the Sub-Categories map).

Using Data Densification to Make More Points

Now we have one circle – but I wanted to make two circles! If we want to put another circle on the same axis, we need more data points. If my outer circle contains Sub-Category, and my inner circle contains Product, I simply do not have enough rows for Tableau to draw both circles. For this we need data densification. The goal of this is to duplicate my data – using the original rows for one circle and their duplicates for another.

There are a few ways to do this in Tableau, but I will show my preferred method. I open excel and create a small table as follows.

I then copy this table from excel, open my Tableau data source editor, double click my data source to open the physical table, and paste the excel cells into the window. It usually takes a few seconds to load, but you will see a join option appear. In both the left and right side of the join, click create join calculation. Then, in the calculated field, enter 1. This is shown below.

Apply this join and look in your data preview. You should find a new column called ‘path’, which takes values of 0 and 1. This duplicates your data – one copy of your data has path=0, and the other path=1. If you, for another task, need more than two copies of your data, you can simply add more values to your path table that you paste into Tableau.

Now, with this densified data we can create another circle. This is a similar process as for creating the previous circle, although it is a little more complex. Images for these steps are shown below, and I will explain some of the differences below also.

The clearest difference between this step and the previous is that I am now using a table calculation to create the angle. The index() function assigns a value along our chosen dimension. The WINDOW_COUNT(COUNT([Product Name])) divides by the number of products (although a count of any field will work). This is like how we divided by 17 previously. Then I multiply by 2 pi again, to convert to radians.

The X and Y calculations are modifications of our previous step. If ATTR([Path])=0, then the calculations use our previous formula. Otherwise, they use our new angle for product, and scale by a new parameter [inner radius]. If you drag these to columns and rows, drag Product Name and Path to details on your marks card, and set X and Y to compute by Product Name, you should see the following circles.

There we have it! Two circles!

Filtering and Selecting with Parameters

Now that we have two circles, we can filter them to show only the Products that belong to a selected Sub-Category. To do this we first create a Selected Category parameter. It is type String, and I have set it to Tables just to test if it works (don’t worry – it won’t do anything yet).

Then create the following calculation and insert it as a filter.

When set to True, this filter allows a row through if it has Path=0 (for the outer circle), OR if it belongs to the Selected Sub-Category. In this way it does not filter the outer circle, which we want to remain unchanged, but filters the inner circle. You should see your inner circle change to show only Products from the Tables Sub-Category.

Now we can draw lines connecting the outer and inner circles. Holding the CTRL key, drag X from your columns just next to itself, on columns. This duplicates it. In your new marks card, change the mark type to line, and change your Path calculation from a detail to a path. You should see the following.

Then you can right click on either of your X columns and convert to dual axis. Synchronise your axes. Then you should see the following.

Now we are almost there! Our final step is to create the parameter action that will allow you to select the outside circle and filter the inner circle. Put your Sheet onto a new Dashboard and navigate to Dashboard Actions (you can use CTRL + SHIFT + D as a shortcut). Then configure a parameter action as follows.

Hit OK, and that’s it! If everything is configured correctly, selecting a Sub-Category (on the outside circle) should filter the inner circle and draw new lines connecting them. It will look something like this.

With some formatting changes, labelling, and inserting measures into your marks, you can achieve something like the viz I demonstrated at the beginning of the blog. Those are the steps to create a cool circle chart in Tableau – I hope you could learn something from each of these tricks.

Code for SubCatNum

case [Sub-Category]

when ‘Accessories’ then 0

when ‘Appliances’ then 1

when ‘Art’ then 2

when ‘Binders’ then 3

when ‘Bookcases’ then 4

when ‘Chairs’ then 5

when ‘Copiers’ then 6

when ‘Envelopes’ then 7

when ‘Fasteners’ then 8

when ‘Furnishings’ then 9

when ‘Labels’ then 10

when ‘Machines’ then 11

when ‘Paper’ then 12

when ‘Phones’ then 13

when ‘Storage’ then 14

when ‘Supplies’ then 15

when ‘Tables’ then 16

END