Dashboards and KPIs¶
Exercise dashboards-and-kpis-annex.pdf · PDF
You are in the middle of a boss fight. How much health do you have left? You know without stopping: a glance at the corner of the screen, half a second, back to the fight. Nobody opens a menu and reads a table to find out if they are about to die.
In Unit 3 you built charts: a bar, a line, a histogram, a scatter, a pie, a heatmap. Each one lives on its own page in Superset. Now imagine a boss with 30 seconds to spare. Do they open seven tabs? No. They need one screen that tells them what matters. That screen is a dashboard, and it is 60% of your RA3 mark.
What you will learn
- Say what a dashboard is for, and tell it apart from a gallery of charts
- Answer the three questions that come before drawing: who reads it, what for, how often
- Order a screen in three bands: KPIs on top, trends in the middle, detail at the bottom
- Tell a KPI from a plain number: it has a definition, a unit and a decision behind it
- Write the formula of four real KPIs for the Steam data and check their values with SQL
- Avoid the trap: why "all my charts on one page" is not a dashboard
A dashboard is the HUD of your data¶
All year we have compared this module to a crafting game: you obtain materials, you prepare them, you analyse them, and at the end you represent them. In a game, that last stage has a name: the HUD (heads-up display), the layer drawn over the game with the health bar, the minimap and the ammo counter.
Why is the health bar a bar in the corner and not a table inside a menu? Because you must read it without stopping to play. A dashboard has exactly the same job.
A dashboard is a single screen that groups the few charts and numbers one audience needs to follow one subject and act on it.
Read that definition slowly. Every piece of it is a rule:
| Piece of the definition | What it rules out |
|---|---|
| A single screen | Ten pages of scrolling. If it does not fit, it is not read at a glance. |
| The few charts and numbers | Everything you happened to build. A dashboard leaves things out on purpose. |
| One audience | "Everybody". A dashboard for everybody is a dashboard for nobody. |
| One subject | A bit of sales, a bit of weather, a bit of staff. One screen, one question. |
| Act on it | Numbers that are interesting but change no decision. |
This is not a classroom invention. In 2004 the data visualisation author Stephen Few wrote an article called Dashboard Confusion because every software company was using the word for something different. His definition became the standard one: a dashboard is "a visual display of the most important information needed to achieve one or more objectives that has been consolidated on a single computer screen so it can be monitored at a glance". Same ingredients: the most important information, one screen, a glance.
Careful: a dashboard is not a gallery
"A dashboard is all my charts on one page." No. That is a gallery: a wall where you hang everything you made. A dashboard starts from the reader's question and throws charts away until only the useful ones are left. A HUD with thirty bars does not make you a better player. It gets you killed.
| Gallery | Dashboard | |
|---|---|---|
| Starts from | The charts you have | The question the reader has |
| Number of charts | All of them | The few that answer the question |
| Order | The order you made them | The order the reader needs them |
| Read in | Minutes, scrolling | Seconds, one screen |
Three questions before you draw anything¶
A game designer does not start by drawing bars. They start by asking what the player needs to know while fighting. Before you open Superset, answer three questions. In class we answer them for our running example, a dashboard called Steam market built on the table games_clean, the cleaned Steam catalogue from Unit 2.
| Question | What it decides | "Steam market" answer |
|---|---|---|
| Who reads it? | The vocabulary, the level of detail, how many charts | A small indie studio about to publish its first game |
| What for? | Which charts stay and which go. One purpose per dashboard | Decide a launch price and know how crowded the market is |
| How often? | A live monitor, or a picture you read once | Read once: the data stops in 2018 |
The audience is the specific person or group the dashboard is made for. The purpose is the decision that the dashboard helps that audience take.
Change the audience and the dashboard changes, even with the same data. A journalist writing about the history of Steam does not care about a launch price. They want the growth of the catalogue, front and centre. Same table, different HUD.
One purpose per dashboard
If you cannot write the purpose in one line, you have two dashboards pretending to be one. Split them. "Decide a launch price" is a purpose. "See things about Steam" is not.
Reading order: three bands¶
Where do you put things? Not wherever they fit. People who read from left to right start at the top-left corner, so that corner is the most expensive spot on the screen. Spend it on the most important thing.
Split the empty screen into three horizontal bands:
| Band | What goes there | In the game |
|---|---|---|
| Top | 3 or 4 KPIs: the big numbers | Health and ammo |
| Middle | Trends and comparisons: line, bar | The minimap |
| Bottom | Detail for the curious: table, scatter, heatmap | The inventory you open on purpose |
The reader who has five seconds reads only the top band and still leaves with the essentials. The reader who has a minute goes down to the middle. Only the curious reach the bottom.
Here is the plan for Steam market, as you would sketch it on paper:
flowchart TB
subgraph TOP ["<b>Top band</b>: the KPIs (health and ammo)"]
direction LR
K1["<b>Games</b><br>26,685"] ~~~ K2["<b>Free share</b><br>11.6%"] ~~~ K3["<b>Median price</b><br>4.99"] ~~~ K4["<b>Hits</b><br>623"]
end
subgraph MID ["<b>Middle band</b>: trends and comparisons (the minimap)"]
direction LR
M1["<b>Line chart</b><br>games released per year"] ~~~ M2["<b>Bar or pie chart</b><br>games per price band"]
end
subgraph BOT ["<b>Bottom band</b>: detail (the inventory)"]
direction LR
B1["<b>Histogram</b><br>how prices are distributed"] ~~~ B2["<b>Scatter plot</b><br>price against Metascore"]
end
TOP --> MID --> BOT
How many charts?¶
Few. The rule of thumb in this course: one screen, at most 8 charts, and every one of them earns its place.
Notice what is missing from the plan above: the heatmap from Unit 3. It is a perfectly good chart. But it does not help a studio choose a price, so it stays out. Leaving a good chart out is the hardest part of the job, and the part that makes the rest readable.
Careful: more charts is not a better dashboard
Each extra chart steals attention from the others. Before adding one, ask: which question of this audience does it answer? If the answer is "none, but it looks nice", it is decoration.
KPIs: numbers with a job¶
The top band holds the KPIs. The word sounds like business jargon, but the idea is simple.
A KPI (key performance indicator) is a number with a definition, a unit and a decision behind it.
Your health bar is a KPI. Definition: hit points left out of the maximum. Unit: points. Decision: under 20%, you stop attacking and heal. Take away any of the three and it is just a number on the screen.
Is "games: 26,685" a KPI for our indie studio? On its own it is context: it says how big the market is, and that is useful to read first. But "median price: 4.99" is the real KPI. It tells the studio where to price.
Here are the four numbers of the top band, each with its formula. A KPI without its formula written next to it cannot be trusted, because nobody knows what was counted.
| KPI | Definition (the formula) | Unit | Value | The decision it feeds |
|---|---|---|---|---|
| Games | COUNT(*) |
games | 26,685 | How crowded is the market? |
| Free share | AVG(is_free::int) |
% of games | 11.6% | Is "free" a normal choice or a rare one? |
| Median price | PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY price) |
dollars | 4.99 | What is a typical launch price? |
| Hits | COUNT(*) where owners_tier = 'Hit' |
games | 623 | How rare is a big success? |
A hit here is a game with at least one million owners. That is the Hit value of the column owners_tier you built in Unit 2 (Categorisation).
You can check all four in one query in SQL Lab:
SELECT COUNT(*) AS games,
ROUND(AVG(is_free::int), 3) AS free_share,
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY price) AS median_price,
COUNT(*) FILTER (WHERE owners_tier = 'Hit') AS hits
FROM games_clean;
| games | free_share | median_price | hits |
|---|---|---|---|
| 26685 | 0.116 | 4.99 | 623 |
is_free is a true/false column. ::int turns true into 1 and false into 0, so the average of the column is the share of free games: 0.116, which is 11.6% (3,094 games out of 26,685).
The doubling test
Not sure whether a number is a KPI? Ask: what would you do differently if it doubled? If the median price doubled to 9.98, the studio would rethink its price. That is a KPI. If the answer is "nothing, it is just interesting", it is trivia, and it does not belong in the top band.
Two KPIs that can lie¶
A KPI is one number, huge, with nothing around it. That makes it powerful, and dangerous: there is no axis, no shape, nothing to warn the reader. Two traps from our own data.
The average that is not typical. Why the median price, 4.99, and not the average? The average price in games_clean is 7.91. You saw the reason in Exploratory statistics: price is skewed. A few very expensive products (the most expensive costs 595.99) drag the average up. Half of all the games cost 4.99 or less. A studio that priced "at the average" would be above most of its rivals.
The average that hides its base. The average Metascore of the table is 71.9. It looks like a quality score for Steam. But run this:
SELECT ROUND(AVG(metascore)::numeric, 1) AS avg_metascore,
COUNT(metascore) AS rated,
COUNT(*) AS games
FROM games_clean;
| avg_metascore | rated | games |
|---|---|---|
| 71.9 | 2849 | 26685 |
Only 2,849 games have a Metascore: 10.7% of the catalogue. And they are not a random sample. They are the games that got enough professional reviews to receive a score at all. So 71.9 describes those games, not Steam.
| KPI on screen | What the reader assumes | What is true | The honest version |
|---|---|---|---|
| Average price: 7.91 | "A typical game costs about 8" | Half the games cost 4.99 or less | Show the median |
| Average Metascore: 71.9 | "Steam games score about 72" | Only 10.7% of games have a score | Show it with its base: n = 2,849 |
Careful: any big number is not a KPI
Making a number huge does not make it important. A KPI needs its definition (what exactly was counted), its unit, its decision and, when it is an average or a share, its base: out of how many?
Try it: sketch on paper first¶
No Superset yet. Professionals sketch dashboards on paper because paper is fast and nobody falls in love with a pencil box. Take a sheet, landscape, and a pencil.
| Step | Do this | You should have |
|---|---|---|
| 1 | At the top, write the audience and the purpose, one line each | "An indie studio about to publish its first game" and "Decide a launch price and know how crowded the market is" |
| 2 | Draw the three bands. In the top band, draw 4 boxes for the KPIs, each with its formula | Games, Free share, Median price, Hits |
| 3 | In the middle and bottom bands, place at most five of your Unit 3 charts as labelled boxes: name and chart type. Under each box, write the question it answers | For example "Line: how fast is the catalogue growing?" |
| 4 | At the side, write one chart you leave out, and why | For example "Heatmap: does not help decide a price" |
The sketch is finished when it has the audience, the purpose, four KPI boxes with formulas, at most five chart boxes with a question each, and one discarded chart with a reason.
A reasonable sketch
Top: the four KPIs. Middle: the line (games per year) and a pie or bar (games per price band). Bottom: the histogram (price) and the scatter (price against Metascore). Left out: the heatmap, which does not help decide a price.
Yours can be different. What matters is that you can defend every box with a question the studio really has.
The dataset behind all of this is on the Resources page.
Key takeaways¶
- A dashboard is a single screen with the few charts and numbers one audience needs to follow one subject and act on it. It is the HUD of your data.
- A dashboard is not a gallery. It starts from the reader's question and leaves charts out: at most 8 on one screen.
- Before drawing, answer three questions: who reads it, what for, how often.
- Order the screen in three bands: KPIs on top (the eye starts top-left), trends and comparisons in the middle, detail at the bottom.
- A KPI is a number with a definition, a unit and a decision. Write its formula next to it.
- KPIs can lie: with skewed data use the median (4.99), not the average (7.91), and always show the base of an average (n = 2,849).
Quick check¶
1. Which of these is the best description of a dashboard?
- A page that shows every chart you have built, so nothing is lost
- A single screen with the few charts and numbers one audience needs to follow one subject and act on it
- A long report that explains the data chapter by chapter
- A table with all the rows of the dataset and a search box
A dashboard is defined by what it leaves out: one screen, one audience, one subject. Every chart you have on one page is a gallery.
2. Which three questions do you answer before drawing a dashboard?
- Which colours, which fonts, which logo
- How many rows, how many columns, how many tables
- Who reads it, what for, how often
- Which chart is the prettiest, the biggest and the newest
The audience (who), the purpose (what for) and the frequency (how often) decide the vocabulary, which charts stay and whether it is a live monitor or a picture read once. Colours come much later.
3. Why do the KPIs go in the top band of the dashboard?
- Because Superset only allows Big Numbers in the first row
- Because small charts must always go above big charts
- Because the eye starts at the top-left, so the most important numbers are read first
- Because the bottom of the screen is reserved for the title
The top-left corner is read first. A reader with five seconds reads only the top band, so that is where the essentials go. Trends go in the middle and detail at the bottom.
4. What turns a plain number into a KPI?
- It is shown in a very large font
- It is bigger than one thousand
- It is calculated with an average
- It has a definition, a unit and a decision behind it
A KPI needs all three. Use the doubling test: if the number doubled, what would the reader do differently? If nothing, it is trivia.
5. In games_clean the average price is 7.91 and the median is 4.99. Why does the Steam market dashboard show the median?
- Because the median is always smaller, and small numbers look better
- Because PostgreSQL cannot calculate an average of prices
- Because price is skewed: a few very expensive products drag the average up, and half the games cost 4.99 or less
- Because the average only works with whole numbers
With skewed data the average is pulled towards the extreme values (one product costs 595.99). The median is the value in the middle, so it describes a typical game.
6. A KPI says 'Average Metascore: 71.9'. What is missing?
- The colour of the number
- The base: it is calculated on only 2,849 of the 26,685 games
- A second decimal
- The name of the database
Only 10.7% of the games have a Metascore, and they are not a random sample. An average that hides its base misleads: show n = 2,849 next to it.
7. Your school wants a dashboard about attendance. Pick the two statements that follow what this page teaches.
- A dashboard for tutors and a dashboard for the head teacher can use the same data but put different KPIs on top
- The best plan is to put every possible chart on one page, so each reader finds their own
- "Share of sessions attended" is a better KPI than "total sessions" if it has a formula and a decision, such as phoning families under 80%
- The KPIs should go at the bottom, so that the reader looks at the detail first
The audience changes the dashboard: a tutor decides about one group, a head teacher about the whole school. And a KPI needs a definition, a unit and a decision. Everything on one page is a gallery, and KPIs go on top.
You have a plan on paper and four KPIs with their formulas. Time to make it real: next, Building a dashboard in Superset.