Skip to content

Building a dashboard in Superset

Exercise building-a-dashboard-annex.pdf · PDF

Most games have a hidden screen in the options called something like "customise HUD". You drag the health bar to another corner, make the minimap bigger, press save, and go back to playing. Nobody plays inside that screen. It exists only to arrange things.

Superset has the same screen. In the previous lesson you designed the Steam market dashboard on paper: an audience, a purpose, three bands. Today you build it. One warning first: Superset will not design it for you. It gives you a grid and some boxes. The sketch is the plan, and without it you are building blind.

What you will learn

  • Build a Big Number chart for each KPI, with a custom SQL metric and a number format
  • Create a dashboard and switch between view mode and edit mode
  • Place and resize charts on the 12-column grid
  • Organise the screen with the six layout elements: header, row, column, tabs, text / Markdown, divider
  • Explain why a dashboard holds a reference to a chart, not a copy
  • Avoid the trap: closing the browser tab does not save your dashboard

First, the KPIs: the Big Number chart

The top band of the sketch needs four KPIs. A bar chart with one bar would be silly. Superset has a chart made for exactly this.

A Big Number is a chart that shows one single value, very large, with nothing around it. Its job is to be read from the door.

It is the ammo counter of the HUD: no axis, no legend, one number.

Build the first one, the share of free games:

Step Do this You should see
1 Charts → + Chart. Dataset: games_clean. Chart type: Big Number (in the category KPI) The chart builder, empty
2 In Metric, open the Custom SQL tab, type AVG(is_free::int) and press Save The metric appears in the box
3 Press Create chart 0.1159
4 Open the Customize tab. In Number format type .1% and press Enter 11.6%
5 Save the chart as UT4 · KPI Free share The chart is in the Charts list

In step 3 the number is correct but unreadable. 0.1159 and 11.6% are the same value. Only the second one is a KPI a human can read at a glance.

A number format is a short code that tells Superset how to write a number on screen: how many decimals, thousands separators, a percent sign. It changes how the number looks, never its value.

Now build the other three the same way. Only the metric and the format change:

Chart name Metric (Custom SQL) Number format Value
UT4 · KPI Games COUNT(*) ,d 26,685
UT4 · KPI Free share AVG(is_free::int) .1% 11.6%
UT4 · KPI Median price PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY price) .2f 4.99
UT4 · KPI Hits COUNT(*), plus a filter owners_tier Equal to (=) Hit ,d 623
Format code Meaning Example
,d Whole number with thousands separators 26.7k becomes 26,685
.1% Percentage with one decimal 0.1159 becomes 11.6%
.2f Always two decimals 4.99

Use those exact chart names. Later you will look for these charts by typing UT4 in a search box, and in a list of forty charts called "Untitled", nobody finds anything.

Three ways a Big Number goes wrong

  • It shows 0.1159 instead of 11.6%. The number format is still Adaptive formatting. Type .1% and press Enter: the number changes at once.
  • function avg(boolean) does not exist. PostgreSQL cannot average true and false. The cast is missing: write AVG(is_free::int).
  • The Hits chart shows 26,685, or 0. With 26,685 the filter was never added. With 0 you typed hit: values are case-sensitive, and the tier is called Hit.

Why Custom SQL for the median?

The Simple tab of a metric offers a short list of aggregates, and the median is not there for every database. The Custom SQL tab lets you type any expression your database understands, such as PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY price).

Edit mode: the "customise HUD" screen

Edit mode is the state of a dashboard in which you can add, move, resize and delete its pieces. View mode is what the reader sees: the finished screen, with no building tools.

View mode Edit mode
In the game Playing The "customise HUD" screen
Who uses it The reader The author
What you can do Read, click tabs Drag, resize, add, delete
How you get there Open the dashboard Edit dashboard, or create a new dashboard
How you leave Save (keep the changes) or Discard (throw them away)

Create the dashboard: Dashboards → + Dashboard. A new, empty dashboard opens, already in edit mode. Click the title and type Steam market.

On the right there is a panel with two tabs:

Tab What is inside
Charts Every saved chart. Type UT4 in the search box to find your KPIs
Layout elements The boxes that organise the screen: header, row, column, tabs, text, divider

Drag a chart from the panel onto the empty area, the canvas, and it is on the dashboard.

Careful: edit mode does not save by itself

"I closed the tab, so it saved." No. Edit mode keeps your changes in the browser until you press Save. Close the tab, or refresh the page, and everything since the last save is gone. Save after every piece of work, like a checkpoint before a boss.

The 12-column grid

Drag UT4 · KPI Games onto the canvas. Drag a second KPI and drop it next to the first: a blue area shows where it will land. Two charts side by side are in the same row.

Now drag the bottom-right corner of a chart. It does not move smoothly. It jumps.

The grid is the invisible ruler of the canvas. A row is 12 columns wide, and every chart is a whole number of columns wide.

The widths in a row can add up to 12 at most. This is all the arithmetic you need:

Charts in the row Widths Sum Result
4 KPIs 3 + 3 + 3 + 3 12 A full row of equal boxes
A wide chart and a narrow one 8 + 4 12 A full row, the wide chart dominates
3 charts as they arrive 4 + 4 + 4 12 Full: a fourth chart is refused
3 charts, one too wide 6 + 4 + 4 14 Does not fit: the third chart cannot enter the row

A chart arrives 4 columns wide. So three KPIs fill the row and the fourth has no room. The fix is to shrink first, then add: resize each KPI to 3 columns, and the fourth fits.

flowchart TB
    subgraph R1 ["<b>Row 1</b>: 3 + 3 + 3 + 3 = 12 columns"]
        direction LR
        A["<b>Games</b><br>3 columns"] ~~~ B["<b>Free share</b><br>3 columns"] ~~~ C["<b>Median price</b><br>3 columns"] ~~~ D["<b>Hits</b><br>3 columns"]
    end
    subgraph R2 ["<b>Row 2</b>: 8 + 4 = 12 columns"]
        direction LR
        E["<b>Line chart</b>: games per year<br>8 columns"] ~~~ F["<b>Bar or pie chart</b>: price band<br>4 columns"]
    end
    R1 --> R2

Careful: one chart per row is a scroll, not a dashboard

The lazy layout is every chart at full width, one under the other. The reader then scrolls through five screens, which is exactly what a dashboard exists to avoid. Drop charts beside each other, on the blue area at the side of a neighbour.

The six layout elements

Charts are not the only thing on a HUD. There are labels, groups, separators.

A layout element is a box that holds no data. It organises or explains the charts around it.

Element What it does In the HUD
Header A section title, in three sizes The label over a group of gauges
Row A horizontal strip, 12 columns wide, that holds charts side by side One line of the HUD
Column Stacks things vertically inside a row Two small gauges piled up
Tabs Several pages in the same space, one visible at a time The inventory tabs
Text / Markdown Free text: a note, the source, a link The tooltip that explains
Divider A thin horizontal line between sections A separator

Two of them deserve a closer look.

Tabs. Remember the bottom band of the sketch: "detail for the curious". Tabs are how you keep detail available without spending screen space on it. The histogram goes in one tab, the scatter in another, and they share the same rectangle.

Text / Markdown. Markdown is a simple way to format text with plain characters: **bold** becomes bold. In a Text / Markdown element you write the note that tells the reader where the data comes from and what it cannot say. Double-click the element to type in it.

Careful: tabs are not bad, and Markdown is not decoration

Tabs hide detail on purpose. The rule is simple: what must be seen at a glance never goes in the second tab. And the note at the bottom is not an ornament. Without the source and the limits of the data, nobody can trust the numbers above it.

A dashboard holds references, not copies

You dragged UT4 · KPI Games onto the dashboard. How many charts called UT4 · KPI Games exist now?

Still one.

A reference is a pointer to something that lives somewhere else, like a shortcut on your desktop. The dashboard does not contain the chart. It points at it.

flowchart LR
    C["<b>Chart</b><br>UT4 · KPI Games<br>(exists once)"]
    D1["<b>Dashboard</b><br>Steam market"] -- "reference" --> C
    D2["<b>Dashboard</b><br>another dashboard"] -- "reference" --> C
You do this What happens
Edit the chart (its title, its metric, its format) Every dashboard that uses it changes too
Remove the chart from the dashboard The chart still exists in the Charts list
Delete the chart itself The dashboard is left with a hole

This is good news and a responsibility. Good news: fix a typo once and it is fixed everywhere. Responsibility: your change reaches dashboards you may have forgotten about.

To change a chart from inside a dashboard, use the three dots on the chart → Edit chart. That is where you shorten a title that is too long for a narrow box.

Try it: Steam market, from paper to screen

Four short tasks. Press Save at the end of each one.

Task 1: the KPI row.

Step Do this You should see
1 Dashboards → + Dashboard. Title: Steam market An empty dashboard in edit mode
2 From Layout elements, drag a Header and type Steam market 2004–2018 · for an indie studio choosing a launch price Audience and purpose, at the very top
3 From Charts, drag three UT4 · KPI charts into one row under the header: Games, Free share, Median price Three numbers side by side, the row is full
4 Resize each to 3 columns, and as short as it will go. Then drag in Hits at the end of the row. Save 26,685 · 11.6% · 4.99 · 623 in one row, same width

Task 2: the middle band.

Step Do this You should see
1 Edit dashboard. Under the KPI row, add a Header: How the market grew A section title
2 In one row, add your Unit 3 line chart (games released per year) and your bar or pie chart (price band). Give the line 8 columns and the other 4 A full row: 8 + 4 = 12
3 Check that titles and axis labels are still readable. If not, shorten the title with the three dots → Edit chart. Save Header, 4 KPIs and 2 charts on the first screen, without scrolling

Task 3: tabs for the detail.

Step Do this You should see
1 Edit dashboard. Drag a Tabs element below the middle band. Rename the first tab Prices. Add a second with the + and call it Quality Two tabs
2 In Prices, place the histogram (price distribution). In Quality, the scatter (price against Metascore) Each tab shows a different chart
3 Under the tabs, drag a Divider and a Text / Markdown. Double-click the text and replace the sample with the note below. Save The source note at the bottom
**Source:** TidyTuesday 2019-07-30 (Steam Spy). 26,685 games released 2004–2018.
Free games count as price 0. Only 2,849 games (10.7 %) have a Metascore.

Do not copy numbers into a note without checking them. Run this in SQL Lab:

SELECT COUNT(*), MIN(release_year), MAX(release_year),
       COUNT(metascore), ROUND(100.0 * COUNT(metascore) / COUNT(*), 1)
FROM games_clean;
count min max count round
26685 2004 2018 2849 10.7

Task 4, if you want more. Put the heatmap in a third tab, Calendar. Then use a Column inside a row to stack two KPIs on top of each other next to a chart. Does it read better than the flat row? Decide, and be ready to say why.

The finished layout:

Band Content Columns
Header Steam market 2004–2018 · for an indie studio choosing a launch price 12
KPI row Games 26,685 · Free share 11.6% · Median price 4.99 · Hits 623 3 + 3 + 3 + 3
Middle Line: games per year · bar or pie: price band 8 + 4
Tabs Prices: histogram · Quality: scatter 12 each
Note Source, size, how free games and missing Metascores are treated 12
If it breaks
Symptom Cause and fix
The chart is not in the Charts tab Untick Show only my charts, or search by name
A dropped chart lands in a new row, or will not drop The row is full. Shrink the charts first, then drag again to the blue area beside the neighbour
A chart refuses to shrink, or looks broken when narrow A long title wraps. Shorten the title in the chart
"There are no charts added to this dashboard" It was saved empty. Edit dashboard and carry on
Everything is gone after a refresh It was never saved. Rebuild the KPI row first and save after every task

Careful: bigger does not mean more important

Position beats size. The top-left is read first, whatever is there. A huge scatter plot on top pushes the KPIs off the first screen, and the reader with five seconds leaves with nothing. Open your dashboard in view mode and ask: what do I read first? Is it the most important thing?

Key takeaways

  • A Big Number chart shows one value, huge. Its metric goes in Custom SQL and its number format (,d, .1%, .2f) makes it readable.
  • Edit mode is the "customise HUD" screen. Nothing is saved until you press Save.
  • The canvas is a grid of 12 columns. Widths in a row add up to 12 at most: four KPIs are 3 + 3 + 3 + 3.
  • Six layout elements organise the screen: header, row, column, tabs, text / Markdown, divider.
  • A dashboard holds a reference to each chart. Edit the chart once and every dashboard changes.
  • Layout is a decision about what the reader sees first: KPIs on top, detail in tabs, the source in a note.

Quick check

1. Your Big Number shows 0.1159 and you want 11.6%. What do you do?
  • Change the metric to AVG(is_free::int) * 100
  • In the Customize tab, type .1% in Number format and press Enter
  • Resize the chart until the number rounds itself
  • Rename the chart to "Free share (%)"

A number format changes how a value is written, not the value. .1% means "percentage with one decimal", so 0.1159 is shown as 11.6%.

2. You worked on your dashboard for twenty minutes in edit mode and closed the browser tab. What happened to your changes?
  • They were saved automatically every minute
  • They are kept in a draft that opens next time
  • They are lost: edit mode only keeps changes when you press Save
  • The charts you added were deleted from the Charts list

Edit mode does not save by itself. Changes live in the browser until you press Save. The charts themselves are safe, because the dashboard only held references to them.

3. How wide is a row of the dashboard grid?
  • 4 columns
  • 8 columns
  • 10 columns
  • 12 columns

The grid is 12 columns wide. Charts arrive 4 columns wide, so three of them fill a row.

4. A row holds three charts of 6, 4 and 4 columns. What happens, and what is a correct fix?
  • Nothing: Superset shrinks them automatically to fit
  • 6 + 4 + 4 = 14, more than 12, so the third chart does not fit; shrink them to 4 + 4 + 4 or move one to another row or a tab
  • The dashboard cannot be saved until you delete a chart
  • The row grows to 14 columns and the reader scrolls sideways

Widths in a row add up to 12 at most. You do not need to delete anything: resize the charts, or move one to a new row or into a tab.

5. Which layout element lets two charts share the same space, one visible at a time?
  • Divider
  • Header
  • Tabs
  • Column

Tabs are several pages in the same rectangle. They are ideal for detail. A column stacks things vertically, but shows them all at once.

6. A classmate fixes a typo in the title of a chart, and the title also changes on another classmate's dashboard. Why?
  • Superset copies every change to all dashboards with a similar name
  • The two dashboards were accidentally merged
  • Both dashboards hold a reference to the same chart, so there is only one chart to edit
  • The second dashboard was open in edit mode at the same time

A dashboard does not contain a copy of the chart. It holds a reference, like a shortcut. There is one chart, and every dashboard pointing at it shows the change.

7. You are laying out a dashboard for a shop owner who looks at it for a few seconds each morning. Pick the two good decisions.
  • Put the three KPIs in the first row, 4 columns each
  • Put the largest and most colourful chart on top, and the KPIs in the second tab
  • Put the detailed table in a tab, and a note with the source at the bottom
  • Give every chart the full 12 columns so that each one is easy to see

Position beats size: the top-left is read first, so the KPIs go there (4 + 4 + 4 = 12). Tabs are for detail, never for what must be seen at a glance. One full-width chart per row is a scroll, not a dashboard.

Your dashboard answers one question about the whole market. But what is the median price of the hits only? Do you need a second dashboard? No: next, Filters and cross-filters.