Sub topic 13
Sorting, labels, axes and color
This chapter assumes you can build a basic visual in Power BI Desktop and that your model already has the measures from earlier chapters, such as [Total Sales]. Choosing the right visual type is only half the work. A correct chart with the wrong sort order, a truncated axis or a rainbow palette still misleads. The goal here is to make the visual's message readable at a glance.
Sorting: put the answer where the eye lands
Power BI sorts a visual by one field at a time. You change it from the More options menu (the three dots) on the visual, then Sort axis, then pick a field and Sort ascending or Sort descending.
Choose the sort by the question the visual answers:
| Question | Sort by | Direction |
|---|---|---|
| Rank categories | The measure (for example `[Total Sales]`) | Descending, so the largest is first |
| Change over time | The date field | Ascending, oldest on the left |
| Compare a fixed set (Low, Medium, High) | A custom order column | The natural order of the set |
| Find a name in a long list | The category name | Ascending (A to Z) |
Two defaults cause trouble. A bar chart often sorts by the measure descending, which is what you want for ranking. A column chart with a text month field sorts alphabetically, which gives April, August, December and so on.
Sort by column for text that has a natural order
When a text field has a natural order, add a numeric column that holds the order, then tell Power BI to sort the text column by it. In the Data view, select the text column, then use Column tools, Sort by column, and choose the numeric column.
The calculated column below groups products into price bands. The labels sort alphabetically by default, so "200 and over" would come first.
Price Band =
SWITCH (
TRUE (),
Product[ListPrice] < 50, "Under 50",
Product[ListPrice] < 200, "50 to 199",
"200 and over"
)Add a second column that supplies the order:
Price Band Order =
SWITCH (
TRUE (),
Product[ListPrice] < 50, 1,
Product[ListPrice] < 200, 2,
3
)Then set Sort by column on Price Band to Price Band Order. Each band must map to exactly one order number. If one label maps to two numbers, Power BI reports an error about the column's many-to-one relationship with the sort column.
Sorting gotchas
- Sorting a visual that has a legend sorts the axis categories, not the legend. The legend order follows its own field's sort setting.
- A sort chosen on the visual is saved with that visual. A sort set on the column in the model applies everywhere that column is used by default.
- Sorting a line chart by the measure scrambles the time sequence. Keep time on the axis ascending.
- Hierarchies and drill-down follow the sort of each level separately.
Data labels: show values without clutter
Data labels print the value on or next to each mark. Turn them on in Format, then Visuals, then Data labels.
Use labels when the reader needs exact values and there are few marks, such as a ranked bar chart with 10 bars. Skip them when there are many marks, as in a daily line chart with 365 points. In that case label only the last point, or add a card for the headline number.
Settings worth knowing:
- Display units: show 1.2M instead of 1,234,567. Set it to Auto or choose a fixed unit, and keep the same unit across visuals on one page.
- Value decimal places: one decimal is usually enough. Showing 1,234,567.89 hides the message.
- Position: for bar charts, Outside end keeps labels readable against the bar color. Inside end works for wide bars with a light font.
- Detail labels: on pie, donut and treemap visuals, choose whether to show the category, the value, the percentage, or a combination.
Format the number once, in the model, so every visual agrees. Select the measure, then use Measure tools to set the format and decimal places. A format set on the measure applies to every visual that uses it, unless the visual overrides it.
When labels overlap, do not shrink the font until it is unreadable. Remove the labels, widen the visual, switch a column chart to a bar chart so category names run horizontally, or filter to the top N.
Axes: scale decides what the reader believes
Start bar and column charts at zero
Bar length encodes value, so the axis must start at zero. If you set the minimum to 90 000 on a chart whose bars range from 95 000 to 100 000, a 5% difference looks like a 10-fold difference. Check Format, then Visuals, then X axis or Y axis, then Range. Leave Minimum empty (automatic) or set it to 0 for bar and column charts.
Line charts are different. Position encodes value, not length, so a non-zero minimum is acceptable when the changes would otherwise be flat. If you do this, say so in the title or a subtitle, for example "Y axis starts at 90,000".
Keep scales consistent across comparable visuals
Small multiples and side-by-side charts can mislead if each has its own automatic scale. A small change in one panel can look as large as a big change in another. For small multiples, Power BI shares the axis range by default. Check that Sync axis or the shared-scale setting stays on when the panels are meant to be compared.
Other axis settings
- Axis type: for a date field, Continuous spaces points by real time. Categorical gives each point equal spacing, even when dates are missing. Use continuous for trends with irregular dates.
- Logarithmic scale: use it only when the audience understands it. Equal steps then mean equal percentage change, not equal amounts.
- Titles: turn the axis title on when the unit is not obvious, and turn it off when the visual title already says it.
- Gridlines: keep light horizontal gridlines on a column chart without data labels. Remove them when labels are on.
- Secondary axis: a combo chart with two axes invites false correlations, because you choose each scale. Prefer two aligned visuals.
Color: use it to carry meaning
Color works best as a signal, not decoration. Three uses cover most reports.
- Highlight one thing. Make all bars a neutral gray or a single brand color and make the important bar stand out.
- Distinguish a few series. Use a legend with no more than about five categories. Beyond that, colors are hard to tell apart.
- Show a quantity. Use a gradient from light to dark for low to high on a single hue, so a map or matrix reads as intensity.
Conditional formatting
Conditional formatting colors marks by a rule. Open Format, then Visuals, then Columns (or Bars), then Colors, then the fx button next to the color. You can base the color on:
- Gradient: a continuous scale between a minimum and maximum color.
- Rules: fixed thresholds, such as red below 0.
- Field value: a color the data itself provides, such as a hex code from a measure.
A rule driven by a measure keeps the logic in one place and is easy to audit:
Growth Color =
IF (
[Sales YoY %] < 0,
"#C0392B",
"#2E7D32"
)Use this measure with Field value to color bars red when sales fell and green when they rose.
Color cautions
- Red and green alone fail for about 1 in 12 men with a color vision deficiency. Pair color with a second cue, such as an arrow, a sign, or a label.
- Do not use a different color per bar when the axis already names each bar. It adds noise and implies a legend that does not exist.
- Keep the same color for the same thing on every page. If "Online" is blue on page one, keep it blue on page two.
- Use a theme (View, then Themes) so palette choices apply across the report, rather than recoloring each visual.
A worked example
Suppose a clustered bar chart ranks product categories by [Total Sales].
- Put
Product[Category]in Y axis and[Total Sales]in X axis. - Sort by
[Total Sales]descending, so the leader is at the top. - Set the X axis minimum to automatic or 0.
- Turn on data labels, with display units in thousands and no decimals.
- Turn off gridlines and the X axis title, because the labels and the visual title carry the information.
- Color all bars gray, then apply a rule or field value so only the top category uses the accent color.
The result answers "which category leads?" in about two seconds.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Months appear as Apr, Aug, Dec | Text field sorts alphabetically | Sort by column using a month number |
| Error when setting Sort by column | One label maps to several order numbers | Make the order column one-to-one with the label |
| Bars look wildly different but values are close | Axis minimum is not zero | Reset the minimum to automatic or 0 |
| Labels overlap | Too many marks | Filter to top N, switch to a bar chart, or drop labels |
| Colors reset after a refresh | Colors were set per data point | Use conditional formatting or a theme |
Exercise
A column chart shows sales by quarter named "Q1", "Q2", "Q3" and "Q4" plus a fiscal-year text such as "FY25 Q1". The columns appear as "FY25 Q1, FY25 Q2, FY26 Q1" sorted alphabetically within the year, and one bar looks twice as tall as another though the values are 98,000 and 100,000. Name the two fixes you would apply.
Show answer
First, add a numeric order column (for example year times 10 plus quarter number) and set Sort by column on the text label so the quarters follow time order. Second, reset the value axis minimum to automatic or 0, because a bar chart's length must start at zero to represent the values honestly.
Exercise
You color bars with a measure that returns red for negative growth and green for positive growth. What additional step makes the chart usable for readers with red-green color blindness?
Show answer
Add a second cue that does not depend on color, such as a plus or minus sign in the data label, an arrow icon, or a label that states the direction.