Toan Hoang

Creating a Multi-Level Dendrogram Charts in Tableau

Since I released my Dendrogram tutorial I have been inundated with requests on how to a multi-level version. So, in this tutorial, we are going to leverage some interesting techniques to get this effect. I hope you enjoy.

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

Load the following data into the Tableau Public / Tableau Desktop

Dimension,Level,Parent,Value
North America,1,,312
South America,1,,217
Europe,1,,290
Asia,1,,70
Africa,1,,194
Mexico,2,North America,95
United States,2,North America,80
Canada,2,North America,77
Panama,2,North America,60
Brazil,2,South America,45
Chile,2,South America,40
Argentina,2,South America,35
Colombia,2,South America,47
Peru,2,South America,20
Venezuela,2,South America,30
Germany,2,Europe,80
United Kingdom,2,Europe,60
France,2,Europe,55
Italy,2,Europe,50
Netherlands,2,Europe,45
China,2,Asia,10
India,2,Asia,15
Japan,2,Asia,20
South Korea,2,Asia,25
South Africa,2,Africa,34
Nigeria,2,Africa,36
Kenya,2,Africa,40
Ghana,2,Africa,30
Tunisia,2,Africa,25
Senegal,2,Africa,29

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 will be performing data densification to be able to draw our curves

Calculated Fields

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

@Continent Parameter

@Region Y Position Parameter

Path (bin)

Filter

IF [Level] = 1 OR ([Level] = 2 AND [@Continent] = [Parent]) THEN
    TRUE
ELSE
    FALSE
END

TC_Level

WINDOW_MAX(MAX([Level]))

TC_Value

WINDOW_SUM(SUM([Value]))/2

TC_Rank

RANK_UNIQUE([TC_Value],"asc")

X

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

Columns

[X]+(([TC_Level])*18)-12

TC_Sigmoid

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

Y

([TC_Sigmoid]*([TC_Rank]-(WINDOW_MAX([TC_Rank])+1)/2)/100)
+IIF([TC_Level] = 2, [@Region Y Position], 0)

TC_Max Y

IF [Y] > 0 THEN
    WINDOW_MAX([Y])
ELSE    
    WINDOW_MIN([Y])
END

Zero

0

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

Worksheet

We will now build our worksheet:

If all goes well, you should see the following:

We will now adjust the Table Calculations to get our Dendrogram:

Simple huh, but if all goes well, you should now see the following:

Now, we will add our text labels:

You should now see the following:

Now, to add our interactivity, we will now add two Parameter actions and a Highlight action.

You should now have the interactive two level Dendrogram:

Lastly, we will adjust the formatting:

You will want to end up with something like 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/Multi-LevelDendragram/Multi-LevelDendrogram

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: https://www.patreon.com/tableaumagic

Exit mobile version