SelfscribeDownloadOpen the app

Sales dashboard

Tiles, charts and tables all worked out from one list of orders. Change an order and everything follows.

Document · Advanced · uses chart, totals, table

Edit it in the playgroundRead the file

What it shows

Build a monthly report whose every figure is worked out from one table.

What you learn

Calculated columns, total tiles, charts by week and by share, a grid of one column across another, a summary table made from a query, panels side by side, a QR code.

Try this

  • Change Sam Whitfield's grinder from refunded to paid, and the revenue tile, both charts and the refunds table change with it.
  • Add an order on 2026-10-31, and the last week's bar grows.
  • Add Oct, 3572, 3400 to the chart of months, and its lines run on to October.
examples/sales-dashboard.self · 167 lines
~~~ selfscribe
# Lesson: Build a monthly report whose every figure is worked out from one table.
# You learn: calculated columns, total tiles, charts by week and by share, a grid of one column across another, a summary table made from a query, panels side by side, a QR code.
# Try this: change Sam Whitfield's grinder from refunded to paid, and the revenue tile, both charts and the refunds table change with it.
# Try this: add an order on 2026-10-31, and the last week's bar grows.
# Try this: add `Oct, 3572, 3400` to the chart of months, and its lines run on to October.
# summary: Tiles, charts and tables all worked out from one list of orders. Change an order and everything follows.
# category: money
# tags: document, advanced, work
# uses: chart, totals, table
use data
set title Sales dashboard
set style sans wide compact
# Prices, revenue and margin show in euros; quantities and counts stay plain numbers.
set currency €

# ---- Colours, each with its shade for dark pages -------------------------------------
palette
  brand  #9c4a1a  dark #f0a875
  soft   color-mix(in srgb, var(--brand) 8%, transparent)
  line   color-mix(in srgb, currentColor 12%, transparent)

# ---- "```chart": figures typed in by hand, drawn as a chart ----------------------------
# Use it for numbers that are not records on this page, like the closed months.
block  ``` chart ... ```     -> chart  verbatim
# ---- "qr: a link" on its own line: a QR code to scan -----------------------------------
line   qr: _                 -> qr

# ---- The header: "kicker left | right" in a strip over the title -----------------------
line   kicker _              -> div.kicker    split "|" span  { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.3em 1em; padding-bottom: 0.8em; border-bottom: 1px solid var(--line); font: 700 0.72em/1.3 var(--doc-font-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brand) }  as sr-kicker
line   note _                -> p.note        { margin: -0.5em 0 1.2em; opacity: 0.7 }  as sr-note

# ---- "::: panel" blocks inside a ":::: pair": two framed panels side by side -------------
# A panel and the footer share the box class: a rounded frame.
class box  { border-radius: 14px; border: 1px solid var(--line) }
block  :::: pair ... ::::    -> div.pair      { display: grid; grid-template-columns: repeat(auto-fit, minmax(17em, 1fr)); gap: 1em; margin: 1em 0 1.6em }  as sr-pair
block  ::: panel ... :::     -> section.panel.box  { padding: 0.9em 1.1em 0.2em }  as sr-panel
class panel > p  { margin: 0 0 0.4em; font-size: 0.85em; opacity: 0.7 }
# "### …" is a small label on this page: it heads each panel.
line   ### _                 -> div.panel-title { font: 650 0.85em/1.3 var(--doc-font-ui); margin-bottom: 0.2em }  as sr-panel-title

# ---- "DO …" on its own line: a decision, gathered into one shaded list -------------------
line   DO _                  -> li.decision   group ul.decisions  { margin: 0.3em 0 }  as sr-decision
class decisions  { padding: 0.8em 1.2em 0.8em 2.4em; border-left: 4px solid var(--brand); background: var(--soft); border-radius: 0 10px 10px 0 }
class decision::marker  { color: var(--brand) }

# ---- "::: footer" … ":::": a framed strip at the foot of the page -----------------------
block  ::: footer ... :::    -> footer.foot.box  { display: flex; align-items: center; gap: 1.2em; margin-top: 1.4em; padding: 1em 1.2em; background: var(--soft); font-size: 0.9em }  as sr-foot
~~~
kicker Ember & Oak Roasters · monthly review | Updated 1 November 2026
# October 2026

note The till, the web shop and the wholesale book, closed on the 31st. All figures in euros.

view: orders as stats filter status = paid sum revenue, margin, orders avg revenue plain

:::: pair
::: panel
### Revenue and margin by week
view: orders as chart by date week sum revenue, margin filter status = paid plain
:::
::: panel
### Where the money came from
view: orders as chart donut by channel sum revenue filter status = paid plain
:::
::::

## What sold where

Each cell is the paid revenue of a product through one channel. Beans carry the month, and the Saturday course on the 24th sold every seat.

```data mix from orders where status = paid per product across channel sum revenue as table plain
```

## Wholesale accounts

The bakery and the cafés that buy by the kilo, largest first.

```data accounts from orders where status = paid and channel = wholesale per customer sum revenue, margin count as hidden
% customer, orders = records, revenue = sum_revenue, margin = sum_margin
```

view: accounts as table columns customer, orders, revenue, margin sort revenue desc plain

:::: pair
::: panel
### How the months compare
The closed months, from the accounts, against the targets set in spring.

```chart
type: line
y: €
Month, Revenue, Target
May, 3120, 3000
Jun, 3340, 3200
Jul, 2890, 3200
Aug, 2710, 3000
Sep, 3460, 3400
```
:::
::: panel
### For November

DO Raise the wholesale price to €20 a kilo from 1 December, with a month's notice.
DO Put the gift box on the web shop's front page before the Christmas orders start.
DO Add a second Saturday course: the October one sold out within a week.
:::
::::

## Refunds

view: orders as table filter status = refunded columns date, customer, product, price sum price plain

The grinder came back with a cracked hopper, and the supplier has credited us. Ruth's beans were lost in the post and sent again.

## The orders

One line per order. Revenue and margin are worked out, so only quantity, price and cost are typed.

```data orders as table columns date, customer, channel, product, qty, price, revenue, status sort date
date:date, customer, channel:choice(web shop|café|wholesale|subscription), product:choice(beans|equipment|gift box|course), qty:number min 1, price:number, cost:number, status:choice(paid|refunded) default paid, revenue = qty * price, margin = qty * (price - cost), orders = 1
2026-10-01, Hart's Bakery, wholesale, beans, 12, 19, 7, paid
2026-10-02, Priya Shah, web shop, beans, 2, 11, 4, paid
2026-10-03, Walk-ins, café, beans, 14, 11, 4, paid
2026-10-04, Tom Okoro, web shop, equipment, 1, 39, 22, paid
2026-10-06, Monthly subscribers, subscription, beans, 46, 10, 4, paid
2026-10-07, The Green Room, wholesale, beans, 8, 19, 7, paid
2026-10-09, Walk-ins, café, gift box, 5, 28, 13, paid
2026-10-10, Elena Rossi, web shop, course, 2, 45, 12, paid
2026-10-11, Walk-ins, café, beans, 19, 11, 4, paid
2026-10-13, Hart's Bakery, wholesale, beans, 12, 19, 7, paid
2026-10-14, Sam Whitfield, web shop, equipment, 1, 129, 84, refunded
2026-10-16, Corner Books Café, wholesale, beans, 6, 19, 7, paid
2026-10-17, Walk-ins, café, beans, 22, 11, 4, paid
2026-10-18, Maya Lindqvist, web shop, gift box, 3, 28, 13, paid
2026-10-20, The Green Room, wholesale, beans, 8, 19, 7, paid
2026-10-21, Ade Bello, web shop, beans, 4, 11, 4, paid
2026-10-23, Walk-ins, café, equipment, 3, 24, 12, paid
2026-10-24, Saturday course, café, course, 6, 45, 12, paid
2026-10-25, Ruth Calder, web shop, beans, 1, 11, 4, refunded
2026-10-27, Hart's Bakery, wholesale, beans, 12, 19, 7, paid
2026-10-28, Walk-ins, café, gift box, 7, 28, 13, paid
2026-10-29, Leo Brandt, web shop, equipment, 2, 39, 22, paid
2026-10-30, Mill Street Kitchen, wholesale, beans, 5, 19, 7, paid
2026-10-31, Walk-ins, café, beans, 25, 11, 4, paid
```

::: footer
qr: https://emberandoak.example/reports/2026-10
**Printed for the roastery wall.** Scan the code for the live page, which follows every order as it comes in.
:::

## How it's made

- Every figure comes from one data block, the orders above. Each `view: orders as …` line draws them again: as tiles, a chart, a donut or a table.
- `revenue = qty * price` and `margin = qty * (price - cost)` in the orders' first line are worked out for each order. `orders = 1` counts each order once, so `sum orders` is how many there were.
- `filter status = paid` leaves the refunds out of every total except their own.
- The grid and the wholesale accounts are data blocks that ask a question of the orders: `from orders where status = paid per product across channel sum revenue`. The closed months are typed into a `chart` block, since they are not records on this page.

## Try it yourself

1. Change Sam Whitfield's order from `refunded` to `paid`. The revenue tile grows by 129, and he leaves the refunds.
2. Add `2026-10-31, Hart's Bakery, wholesale, beans, 6, 19, 7, paid` to the orders. The last week's bar and the wholesale slice grow.
3. Add `Oct, 3572, 3400` to the end of the chart of months. Its lines run on to October.
4. Write `DO Order more gift boxes for December.` under "For November". It joins the shaded list.

Next: *Household budget* totals a household's bills the same way. *Sign-up and feedback* fills a table from a form.