0
0
Power-biHow-ToBeginner ยท 3 min read

How to Create a Treemap in Power BI: Step-by-Step Guide

To create a Treemap in Power BI, select the Treemap visual from the Visualizations pane, then drag a categorical field to the Group area and a numeric field to the Values area. This will display your data as nested rectangles sized by the numeric values.
๐Ÿ“

Syntax

In Power BI, creating a treemap involves selecting the Treemap visual and assigning data fields to its roles:

  • Group: The category or hierarchy field that defines the rectangles.
  • Values: The numeric field that determines the size of each rectangle.
  • Details (optional): Additional fields to break down groups further.

No code is needed; it is done through drag-and-drop in the Power BI interface.

power_bi
1. Open Power BI Desktop.
2. Load your dataset.
3. Click the Treemap icon in the Visualizations pane.
4. Drag a categorical field (e.g., Product Category) to the Group area.
5. Drag a numeric field (e.g., Sales Amount) to the Values area.
6. Optionally, drag another field to Details for more granularity.
๐Ÿ’ป

Example

This example shows how to create a treemap that displays sales by product category:

  • Load a sales dataset with fields: ProductCategory and SalesAmount.
  • Select the Treemap visual.
  • Drag ProductCategory to Group.
  • Drag SalesAmount to Values.

The treemap will show rectangles sized by sales amount for each product category.

plaintext
/* Power BI Desktop steps - no scripting needed */

// Dataset example:
ProductCategory, SalesAmount
"Bikes", 10000
"Accessories", 5000
"Clothing", 7000

// Visual setup:
// 1. Select Treemap visual
// 2. Group: ProductCategory
// 3. Values: SalesAmount
Output
A treemap visual with three rectangles labeled Bikes, Accessories, and Clothing sized proportionally to their sales amounts.
โš ๏ธ

Common Pitfalls

Common mistakes when creating treemaps in Power BI include:

  • Not assigning a numeric field to Values, resulting in an empty or incorrect visual.
  • Using too many categories, which makes the treemap cluttered and hard to read.
  • Ignoring data hierarchy, which can be added using the Details field for better insight.
  • Not formatting labels or colors, which reduces readability.

Always check that your numeric data is aggregated correctly (sum, count, etc.) in the Values field.

plaintext
/* Wrong way: Missing numeric field */
// Group: ProductCategory
// Values: (empty)

/* Right way: Include numeric field */
// Group: ProductCategory
// Values: SalesAmount
๐Ÿ“Š

Quick Reference

FieldPurposeNotes
GroupDefines categories or hierarchyRequired for treemap structure
ValuesNumeric data to size rectanglesMust be numeric and aggregated
DetailsOptional sub-categoriesAdds more granularity
TooltipsAdditional info on hoverImproves user understanding
FormatCustomize colors, labels, and layoutEnhances readability
โœ…

Key Takeaways

Select the Treemap visual and assign a category to Group and a numeric field to Values.
Ensure the numeric field is aggregated properly to size rectangles correctly.
Avoid too many categories to keep the treemap clear and readable.
Use Details field to add hierarchy and improve insight.
Format labels and colors for better visualization clarity.