My initial name for this tutorial was the Orgasmatron (head massager company name out of Australia), the name is fun, strange as hell but we have to have some fun right? Truth be told, I did not know what to name this delightful little chart type, so I asked Twitter and Facebook and most people said a Head / Scalp Massager; I was informed that there is an actual name for this would be a Dendrogram, so we will look at creating a Single-Level (Generation) Dendrogram in Tableau.

Note: This is an alternative type of data visualisation, and sometimes pushed for by clients. Please always look at best practices for data visualisations before deploying this into production.

Data

We will start by loading the following data into Tableau Desktop / Tableau Public.

CountryValue
United States95
United Kingdom70
France60
Germany55
Japan50
Italy65
Australia80
Canada80
Mexico75
Singapore90

Once your data is loaded into Tableau, right-click on the data source and click on Edit Data Source… with the Data Source Editor open, paste the following:

Path
1
100

Note: If you are using Tableau 2020.2 or great i.e. have access to new Relationship Model, you will need to double-click on the originally pasted data source to open up before pasting in the Path Data.

You should get an error as there is no joining column, however, click on Add new join clause, go to Create Join Calculation, type 1 and click OK. Do this for the right-hand side as well. Ensure that you have Inner join selected and you should see the following:

Note: we need additional records as we are going to be drawing lines and using densification to get more points on our canvas. For more information, check out our article on Data Densification.

Calculated Fields

With our data set loaded into Tableau, we are going to create the following Bin and Calculated Fields:

Path (bin)

  • Right-click on Path, go to Create and select Bins…
  • In the Edit Bins dialogue window:
    • Set New field name to Path (bin).
    • Set Size of bins to 1.
    • Click Ok.

TC_Value

WINDOW_SUM(SUM([Value]))/2

TC_Rank

RANK_UNIQUE([TC_Value],"asc")

X

((INDEX()-1)*0.12)-6

Using Data Densification, we are going to create 100 points from -6 to 6 with a step size of 0.12. This is required for the Sigmoid function that we will use to create a curved line.

TC_Sigmoid

1/(1+EXP(-[X]))

This is the Sigmoid Function that will take the X points and draw a curve.

Y

[TC_Sigmoid]*([TC_Rank]-(WINDOW_MAX([TC_Rank])+1)/2)/100

This is where the magic happens, and we adjust the value returned by the Sigmoid curve based on the rank of the country. On top of this, we want the middle point to be zero, so we subtract a value based on the number of countries or max rank.

With this done, let us start creating our data visualisation.

Worksheet

We will now build our first worksheet:

  • Change the Mark Type to Line
  • Drag Country onto the Detail Mark
  • Drag Path (bin) onto the Columns Shelf
    • Right-click on this pill and ensure that Show Missing Values is selected
    • Drag this pill onto the Path Mark
  • Drag X onto the Columns Shelf
    • Right-click on this pill, go to Compute Using and select Path (pin)
  • Drag Y onto the Rows Shelf
    • Right-click on this pill, go to Compute Using and select Path (bin)

If all goes well, you should now see the following:

We will now adjust the Table Calculations to get our basic shape:

  • Right-click on the Y Pill on the Rows Shelf and select Edit Table Calculations
    • In Nested Calculations select TC Rank
      • In Compute Using select Specific Dimensions
      • Ensure that only Country is selected
    • In Nested Calculations select Y
      • In Compute Using select Specific Dimensions
      • Ensure that only Country is selected

You should now see the following:

We will now adjust the cosmetics to get our final data visualization:

  • Drag TC_Value onto the Size Mark
    • Right-click on this pill, go to Compute Using and select Path (bin)
  • Drag TC_Value onto the Color Mark
    • Right-click on this pill, go to Compute Using and select Path (bin)
    • Click on the Color Mark and adjust the Color
  • Drag Value onto the Label Mark
    • Click on the Label Mark and set Marks to label as Line Ends
    • Edit the Label
  • Hide the Axis Headers
  • Hide the Grid Lines
  • Hide the Zero Lines

You will now want to have the following:

and boom, we are done! I hope you enjoyed creating this data visualization and learned some cool techniques as well. As always, you can find this data visualisation on Tableau Public at https://public.tableau.com/profile/toan.hoang#!/vizhome/Single-LevelDendrogramCharts/Single-LevelDendrogram

Extra Credit: reverse the Rows and Columns and have some fun with it.

Summary

I hope you all enjoyed this article as much as I enjoyed writing it and as always do share the love. Do let me know if you experienced any issues recreating this Visualization, and as always, please leave a comment below or reach out to me on Twitter @Tableau_Magic. Do also remember to tag me in your work if you use this tutorial.

If you like our work, do consider supporting us on Patreon, and for supporting us, we will give you early access to tutorials, exclusive videos, as well as access to current and future courses on Udemy:

Also, do be sure to check out our various courses:

12 COMMENTS

  1. I tried using Sample superstore data using Dimension Country and Measure Sales, I was not able to get the required dendrogram. Is there any different way to create using any data.

    • Hi Shaunak, can you please let me know more about what you saw? Yes, if you can do this with the Sample Superstore, you should be able to do this with any data set.

  2. Hi Toan,
    Followed the Dendrogram tutorial w great results except for one small item, maybe a rookie mistake. I could not get my country/value labels to reside distinctly to the right of the dendrils. Mine seemed to be hitting a wall. Tried all the Label formatting/dragging options I could find……any thoughts? Thank you

  3. Hi, after dragging Y to the row-shelf, my graph show 2 dots instead of line. I made sure that mark type is Line and Path is Path(bin). Can you please give me some suggestions?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.