Sub topic 4
Comparing and Ranking Categories with Bar and Column Charts
This chapter assumes you can build a basic visual on the Power BI Desktop canvas. It also assumes you have a loaded data model with relationships and understand sum, average and count. You should already know the difference between a categorical field and a numeric field, and between a column and a measure.
When a comparison question calls for a bar or column chart
Bar and column charts answer questions such as "Which category sold the most?" and "How do regions compare?" Both draw one rectangle per category, and the rectangle's length encodes the value. Readers judge length along a common baseline more accurately than they judge angle or area, which is why these charts are the default for comparison.
- A bar chart is horizontal. Use it when category names are long or when there are many categories.
- A column chart is vertical. Use it when categories have a natural order, such as size bands, or when there are only a few short labels.
For ranking, prefer a bar chart sorted by value. The reader scans down a list that reads from largest to smallest.
Building the chart
Start with the base measure from the data model. A measure is a DAX formula that is calculated in the context of the visual.
Total Sales = SUM ( Sales[SalesAmount] )- Select Clustered bar chart in the Visualizations pane.
- Drag
Product[Category]to Y-axis. For a column chart, the field goes to X-axis. - Drag
[Total Sales]to X-axis (or Y-axis on a column chart). This is the Values role. - Open the More options menu (the three dots) on the visual, choose Sort axis, and pick Total Sales with Sort descending.
Each bar is now one category, and its length is the total sales of that category.
Choosing the variant
| Variant | Use it for | Watch out for |
|---|---|---|
| Clustered | Comparing a few series side by side within each category | Gets crowded beyond about three series |
| Stacked | Total per category, with a rough split by series | Only the bottom segment shares a baseline, so inner segments are hard to compare |
| 100% stacked | Share of each series within each category | Hides absolute totals |
If the question is purely "which is biggest," use one series. Adding a Legend field to a clustered chart multiplies the bars quickly.
Common errors
- Sorting by category name. The default sort is alphabetical, which hides the ranking. Sort by the measure instead.
- A truncated axis. Bar length is the signal, so the axis must start at zero. Check Format > X-axis > Range if the minimum was set manually.
- Too many categories. Beyond roughly 15 to 20 bars, use a Top N filter on the visual's Filters pane, or move the detail to a table.
- Using columns for long labels. Power BI rotates or truncates the text. Switch to a bar chart.
Exercise
A manager wants to see the 10 products with the highest sales, and product names are long. Which visual and settings do you use?
Show answer
Use a clustered bar chart with Product name on the Y-axis and [Total Sales] as the value. Add a Top N filter set to Top 10 by [Total Sales], and sort the axis by Total Sales descending. The bar chart keeps the long names readable, and the sort shows the ranking.