Power BI Treemap is used to display the data in Rectangle Boxes. You can define the rectangle box using any Dimension column and its size by Measure value.
The Treemap is very useful for displaying the largest data in a small region. For this Create a Power BI Treemap demonstration, we will use the SQL Data Source we created in our previous article.
How to Create a Power BI Treemap?
To create a Power BI tree map, first, drag and drop the Sales Amount from the Fields section to Canvas. Then, it automatically creates a Column Chart. Please refer to the Connect to SQL Server and Charts article to understand the Power BI Data Source.
By clicking the Treemap under the Visualization section, automatically convert the Column Chart into Treemap.
Next, let me add the English Product Name from DimProduct Table to the Group section. It divides the rectangle boxes based on the Sales amount by each product.
Create a Treemap Approach 2
When you click on the Treemap present in the Visualization section, it creates a chart with dummy data.
To add data to Power BI TreeMap, we have to add the required fields:
- Group: Please specify the Column that divides the Rectangle Boxes.
- Values: Any Numeric value, such as sales amount, Total Sales, Customer count, etc.
Let me drag and drop the Sales from the Fields section to the Values field.
Next, add the Department Name from the DimEmployee table to the group section. You can do this by dragging the Department Name to the Group section or checkmark the Department Name column.
Now you can see the TreeMap of Sales Amount divided by Employees Department Name. Hover over any box that shows the tool tip of the Department Name and its Sales Amount.
Let me do some quick formatting to the Power BI Tree map. I suggest you refer to the Formatting section to understand the steps involved in formatting the Power BI TreeMap Box Colors, Title font, Title alignment, Data labels, and colors.
Format TreeMap in Power BI
How to Format TreeMap in Power BI with an example? It includes changing the Box Color, TreeMap Title position, background Colors, Data labels, etc.
To demonstrate these formatting options, we are going to use the Treemap that we created earlier. Please click the Format button to see the list of available formatting options for the tree map.
Format Legend of a Tree Map in Power BI
To display the Legend, select the Legend region and change the option from Off to On. From the below screenshot, you can see the legend.
Format Power BI Tree Map Data Colors
By default, Power BI IntelliSense assigns random colors to each rectangle box. But using this Data Colors section, you have the option to change these colors as per your requirements.
We changed the rectangle Box of a Finance to Pink for the demonstration purpose.
Enable Data Labels on TreeMap in Power BI
Data Labels are used to display information about the rectangle box. In this case, it displays the Sales Amount of each rectangle box. To enable data labels, please toggle the Data labels option to On.
From the screenshot below, we changed the Color, Display Units from Auto to Thousands, and Font family to Arial Black.
Format Category Labels of a Power BI Tree Map
Category Labels are a Dimension value (Group Value) representing a rectangle box. From the screenshot below, you can see that we changed the color of a category Label, the Text Size to 14, and the Font family to Georgia.
Format Title of a TreeMap in Power BI
Please select the Title and toggle the option from Off to On to display the Treemap title. The following is the list of options available to format the Treemap title.
As you can see from the screenshot below, we changed the Title Text to Sales Amount by Department Name. Next, the Font style to Georgia, the Font Size to 20, and the Title Alignment to the center.
Add Background Color to TreeMap in Power BI
You can add the Background color to Treemap by toggling the Background option to On. For the demonstration purpose, we are adding Yellow as the background color. Here, you can change the Transparency percentage as well.
The screenshot below shows you the Treemap after formatting.
Click on the Treemap icon under Visualization, and it will automatically generate. In addition, add Sales (Measure) to the Values section and a dimension (stages) to Category. There is an option to add another dimension to the details to divide the rectangles further.
Treemaps use rectangular boxes with different colors to represent the hierarchal data. Each row represents a rectangle, and the measure value defines its size. The bigger the size, the more sales; the smaller the size, the fewer sales.
If you have hierarchal data with different nested levels, then Treemap is the ideal chart to represent that data.
Yes. Place the dimension field on the Details section, which will further divide each rectangle based on the details section value.
Yes. The rectangle boxes are sorted based on the Measure (Sales) value where the largest is top left and the smallest is bottom right.