Sub topic 7
Highlighting one number: cards, KPIs and gauges
This chapter assumes you can build a report page in Power BI Desktop, that your model already has a Sales table and a marked date table, and that you know the difference between a column and a measure. A single-value visual answers one question: "What is the number, and is it on track?" The sections below cover the three built-in options for that question and when to pick each.
The three visuals
- Card: shows one value and a label. Use it when the number needs no comparison. Total sales for the selected period is a typical case.
- KPI: shows a value, a trend axis behind it, and a target. Use it when the reader needs to know whether the value is good or bad compared with a goal or the prior period.
- Gauge: shows a value on a dial between a minimum and a maximum, with an optional target. Use it only when a bounded range matters, such as a percentage of quota.
All three need a measure, not a raw column. The measure controls how the value is aggregated and how filters affect it.
Build a card
Start with the base measure from the earlier chapters:
Total Sales = SUM ( Sales[SalesAmount] )Drag [Total Sales] into the Fields well of a card visual. The card now responds to slicers and cross-filtering on the page.
Build a KPI
A KPI needs three inputs: an indicator, a trend axis, and a target. A year-over-year comparison gives you all three from measures you already know:
Sales LY =
CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )Set the KPI's fields as follows:
| Well | Field | Purpose |
|---|---|---|
| Value | `[Total Sales]` | The current number |
| Trend axis | `'Date'[Month]` | Draws the area behind the number |
| Target | `[Sales LY]` | The goal the value is compared with |
The KPI colors the value green when it meets or beats the target and red when it falls short. For a cost measure, where lower is better, change this under the visual's color settings.
For a percentage change, a card can show this measure instead:
Sales YoY % =
DIVIDE ( [Total Sales] - [Sales LY], [Sales LY] )DIVIDE returns blank rather than an error when the prior-year value is zero or blank. A blank card is easier to understand than a divide-by-zero error.
Common errors
- KPI shows no trend: the trend axis is empty or not a date field. Add a date column.
- Prior-year value is blank:
SAMEPERIODLASTYEARneeds a marked date table with continuous dates. - Gauge looks empty: the maximum is unset, so Power BI guesses a range. Set minimum, maximum and target explicitly.
- Several gauges on one page: each dial uses a lot of space for one number. A row of cards or KPIs is easier to compare.
Exercise
A sales manager wants to see whether this year's monthly sales are ahead of last year's. Which visual and which measures would you use, and why not a gauge?
Show answer
Use a KPI with [Total Sales] as the value, 'Date'[Month] as the trend axis, and [Sales LY] as the target. The KPI shows the current value, the trend, and whether it meets the goal. A gauge needs a fixed minimum and maximum, and prior-year sales has no natural upper limit, so a dial would not fit.