How to Make a Treemap in Tableau
Tableau Basics
What is a Treemap?
A treemap chart is used to visualize hierarchical data in the form of nested rectangles. Each level is depicted as a colored rectangle, often called a branch, which contains other rectangles (aka leaves). The space inside each of the rectangles that composes a treemap is highlighted based on the quantitative value in the corresponding data point. This type of visualization is super satisfying and simple to make, let’s get started!
Loading the Data Source
Let’s get started by connecting to a data source in Tableau. I recommend connecting to a Google Sheet or Excel file and using data that has classifications you want to breakdown.
I’ll be using data from fbref.com, specifically goalkeeping stats from the 2021 CONCACAF Gold Cup.
Getting Started
For this tutorial, I am going to create a breakdown of the number of saves each keeper made during this tournament. First, click on Show Me in the top right corner of the Tableau window. Here you can see the visualization types you can create in Tableau. You can find the requirements (green circle) for each visualization by hovering your mouse over it. The treemap can be found inside the red circle.
Dimension and Measure Selection
As you can see in the image above, the tree map requires 1 or more dimensions and 1 or 2 measures. Since we want to see a breakdown of the number of saves each keeper made, drag the player dimension into Columns and Saves into Rows like so.
After dragging the fields into columns and rows, the treemap icon under “Show Me” should light up (shown on the left). This means that you have the necessary data needed to produce a treemap.
Once you click on the treemap icon, this should be the outcome. It is starting to take shape, but by playing with the Marks section we can display more information.
Customization
Under Marks (green circle), I placed Saves under Label so we can read the number of saves each keeper made. You could also drag other metrics and information under Tooltip so you can display more data associated with the player. It will be displayed when you are hovering over an individual rectangle with your mouse. In the SUM(Saves) box (blue circle), by hovering over the box you can click on a downward arrow in the top right corner. There you can see an option to edit the color spectrum of the treemap. I decided to change the color to gold for the Gold Cup. I also only wanted to only include keepers that played more than 1 game in the treemap so I dragged the 90’s metric under Filters (red circle) and adjusted the range to players who played at least 1 90.
Final Product
Once I drag the sheet that contains the treemap into a dashboard, set a background color, and add a title, this is the final product! Hope this tutorial was helpful. It is super easy and quick to create and I hope you all give it a shot. I highly recommend to play around with the Marks section to see how you can further manipulate and elevate this visualization type. Keep an eye out for more beginner tableau tutorials in the future, and as always, feedback and shares are appreciated!
Follow me at @FcAyushNarayan on Twitter