Tableau Treemap is used to display the data in Rectangle Boxes. We can define each rectangle box using any of our Dimension member and size by Measure value. Treemaps in Tableau are very useful to display the largest data set information in a small data region.
In this article, we will show you, How to Create Tableau Treemap with an example. For this we are going to write the Custom SQL Query against the SQL Server Data Source. So, Please visit Connecting Tableau to SQL Server article to understand the configurations.
Custom SQL query we are going to use for this report is:
-- Query for Tableau Tree Map SELECT Geo.EnglishCountryRegionName, Geo.StateProvinceName, Geo.City, Prod.EnglishProductName, Prod.Color, Fact.OrderQuantity, Fact.TotalProductCost, Fact.SalesAmount, Fact.TaxAmt, Fact.[Freight] FROM DimProduct AS Prod INNER JOIN FactInternetSales AS Fact ON Prod.ProductKey = Fact.ProductKey INNER JOIN DimSalesTerritory AS Terry ON Terry.[SalesTerritoryKey] = Fact.[SalesTerritoryKey] INNER JOIN DimGeography AS Geo ON Geo.[SalesTerritoryKey] = Terry.[SalesTerritoryKey]
First Approach to Create Tableau Treemap
In this example, we are going to create a Treemap for State dimension against the Sales Amount size. First, Drag and Drop the State Dimension from Dimension Region to Text Field in Marks Shelf
From the below screenshot you can see the available State names in Tableau report
Next, Drag and Drop the Sales from Measures Region to Size Field in Marks Shelf as shown below
Once you drag them, following screenshot will be displayed. By default, Tableau Desktop is displaying TreeMap with State Name as rectangle Text filed and Sum of Sales Amount as the Box size.
From the below screenshot you can observe that, Box Size of a California State is bigger than remaining states because the Sales Amount is higher than other states.
Let us add color to the Tableau Treemap by dragging the Calculated field Profit to Colors field in Marks Shelf as shown below
Once you are done, the following screenshot will be displayed. State name Box with Maximum Sales will be filled with Dark Green and Least Sales Amount with light green
Let us add SalesAmount and Profit values to the Text field as well. By this, you can see the State name along with the SalesAmount and Profit. To do this, Please drag the Sales and Profit from Measures region to Text field present in Marks Shelf
Tableau Treemap text format
In order to format the Data Labels, Please click on the Text field inside the Marks Shelf. Once you click on it, following window will be displayed. For now, we are doing basic formatting so, click on the … button beside the text
Here, we added extra text Sales, Profit beside the < SUM(SalesAmount) > and < SUM(Profit) > and also change the font style to Lucida Sans
From the below screenshot, you can see the Formatted Text
Create a Tableau Treemap – Second approach
This method is very easy and straightforward. Please press and hold the control key and then select the Dimension (s), Measure(s) from the respective region and select the Treemap from the Show Me window
Once you are done, the tableau desktop will create a Treemap for you as shown below
Thank You for Visiting Our Blog