Household budget
Every bill in one table, added up to the cent, with a chart and a list of what is still to pay.
What it shows
Total a household budget with a data block.
What you learn
Typed columns, a plan whose totals come from another table, tiles and a chart from the same rows, a list of what is unpaid, calculator lines.
Try this
- Tick paid for Energy, and "spent" rises by 96.40 while "still to pay" drops by the same.
- Change Fun's plan from 150.00 to 200.00, and its row stops showing red.
- Add a bill
Window cleaner, Home, 18.00, 2026-09-20, no, and the Home bar and the tiles follow.
Maya and Tom · joint accountUpdated 26 September
September 2026
Pay goes in on the 25th. Tick a bill when it leaves the account.
£1,627.88spent
£1,009.55still to pay
£82.57left
Planned and billed, by category, in pounds
Bills
| item | amount | due | paid |
|---|---|---|---|
| Home 6 · Amount £1,455.25 | |||
| Rent | £1,095.00 | ||
| Council tax | £172.00 | ||
| Home insurance | £18.65 | ||
| Energy | £96.40 | ||
| Broadband | £32.00 | ||
| Water | £41.20 | ||
| Food 3 · Amount £420.65 | |||
| Veg box | £22.00 | ||
| Groceries | £312.45 | ||
| Lunches at work | £86.20 | ||
| Transport 3 · Amount £231.25 | |||
| Train pass | £142.00 | ||
| Car insurance | £46.75 | ||
| Bike repair | £42.50 | ||
| Fun 4 · Amount £180.28 | |||
| Streaming | £17.98 | ||
| Climbing passes | £39.00 | ||
| Birthday dinner | £64.80 | ||
| Concert tickets | £58.50 | ||
| Savings 2 · Amount £350.00 | |||
| Boiler fund | £200.00 | ||
| Rainy-day pot | £150.00 | ||
| Total | £2,637.43 | ||
Still to pay
- Energy
- Water
- Birthday dinner
- Boiler fund
- Rainy-day pot
- Concert tickets
- Groceries
- Lunches at work
Amount £1,009.55
The plan
What each category may take this month. A row in red has gone over.
| category | planned | billed | spent | still to pay | left |
|---|---|---|---|---|---|
| Home | £1,480 | £1,455.25 | £1,317.65 | £137.60 | £24.75 |
| Food | £480 | £420.65 | £22.00 | £398.65 | £59.35 |
| Transport | £260 | £231.25 | £231.25 | £0.00 | £28.75 |
| Fun | £150 | £180.28 | £56.98 | £123.30 | -£30.28 |
| Savings | £350 | £350.00 | £0.00 | £350.00 | £0.00 |
| Total | £2,720 | £2,637.43 | £82.57 |
The boiler fund
The boiler is fourteen years old. The quote for a new one came in August.
boiler quote £2,850 =
saved by August £1,250 =
still to save = boiler quote - saved by August =
months to go = still to save / £200 =
Eight more payments of £200 make 8 * £200, so the new boiler goes in next May.
How it's made
- Every bill is one line of the
billsdata block. Its first line types the columns:amount:numberadds up to the cent,due:datesorts as a date andpaid:boolis a box to tick. category:choice(from plan.category)ties each bill to a line of the plan. There,billed = sum(bills.amount)adds up that category's bills, andleft = planned - sum(bills.amount)is what remains.- The tiles at the top are
view: plan as stats sum spent, "still to pay", left plain. The chart under them reads the same rows:as chart hbar by category sum planned, billed. - The boiler fund is a
calcblock. A line that ends in=shows its result, and a name on the left keeps it for the lines below.
Try it yourself
- Tick paid for Energy. "spent" rises by 96.40 and "still to pay" drops by the same.
- In the plan, change Fun from 150.00 to 200.00. Its row is no longer red, and "left" grows by 50.
- Add a bill
Window cleaner, Home, 18.00, 2026-09-20, no. It joins Home, and the Home bar grows. - In the boiler fund, change
/ £200to/ £250. The months to go drop from 8 to 6.4.
Next: Invoices totals line items per client. Sales dashboard draws its tiles and charts from a list of orders.
~~~ selfscribe
# Lesson: Total a household budget with a data block.
# You learn: typed columns, a plan whose totals come from another table, tiles and a chart from the same rows, a list of what is unpaid, calculator lines.
# Try this: tick paid for Energy, and "spent" rises by 96.40 while "still to pay" drops by the same.
# Try this: change Fun's plan from 150.00 to 200.00, and its row stops showing red.
# Try this: add a bill `Window cleaner, Home, 18.00, 2026-09-20, no`, and the Home bar and the tiles follow.
# summary: Every bill in one table, added up to the cent, with a chart and a list of what is still to pay.
# category: money
# tags: interactive, simple, home
# uses: totals, chart, table
#
# ---- "```data NAME" ... "```": a table of rows, and "view: NAME ..." to show it again -------
# `use data` brings the Markdown rules plus data blocks and views. The first line of a data
# block names the columns, and a type after a colon makes amounts add up and dates sort.
use data
set title Household budget
set style sans
# Amounts show in pounds: `set currency` puts £ on every column that holds money.
set currency £
# ---- Colours, each with its shade for dark pages ----------------------------------------
palette
ink #1d3b34 dark #cfe7df
money #1f7a5c dark #6fd3a8
soft color-mix(in srgb, var(--money) 8%, transparent)
line color-mix(in srgb, currentColor 14%, transparent)
# ---- "kicker left | right" above the title: a strip across the page; "note ..." under it ---
line kicker _ -> p.kicker split "|" span { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.3em 1em; margin: 0; padding-bottom: 0.9em; 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(--money) } as bg-kicker
line note _ -> p.note { margin: -0.4em 0 1.4em; font-size: 0.95em; opacity: 0.75 } as bg-note
# ---- "### ..." is a small label on this page, over a chart ---------------------------------
line ### _ -> div.label { margin: 1.6em 0 -0.4em; font: 650 0.85em/1.3 var(--doc-font-ui); color: var(--ink) } as bg-label
# ---- "```calc" ... "```": calculator notes; a line ending in = shows its result ------------
block ``` calc ... ``` -> calc verbatim
# [calc 2 * 3] works a sum out inside a sentence.
inline [calc _] -> calc kind=inline verbatim
~~~
kicker Maya and Tom · joint account | Updated 26 September
# September 2026
note Pay goes in on the 25th. Tick a bill when it leaves the account.
view: plan as stats sum spent, "still to pay", left plain
### Planned and billed, by category, in pounds
view: plan as chart hbar by category sum planned, billed plain
## Bills
```data bills as table columns item, amount, due, paid group category sum amount
item, category:choice(from plan.category), amount:number, due:date, paid:bool, cleared = if(paid; amount; 0.00), unpaid = if(paid; 0.00; amount)
Rent, Home, 1095.00, 2026-09-01, yes
Council tax, Home, 172.00, 2026-09-01, yes
Home insurance, Home, 18.65, 2026-09-08, yes
Energy, Home, 96.40, 2026-09-12, no
Broadband, Home, 32.00, 2026-09-15, yes
Water, Home, 41.20, 2026-09-18, no
Veg box, Food, 22.00, 2026-09-04, yes
Groceries, Food, 312.45, 2026-09-30, no
Lunches at work, Food, 86.20, 2026-09-30, no
Train pass, Transport, 142.00, 2026-09-01, yes
Car insurance, Transport, 46.75, 2026-09-05, yes
Bike repair, Transport, 42.50, 2026-09-09, yes
Streaming, Fun, 17.98, 2026-09-03, yes
Climbing passes, Fun, 39.00, 2026-09-06, yes
Birthday dinner, Fun, 64.80, 2026-09-19, no
Concert tickets, Fun, 58.50, 2026-09-27, no
Boiler fund, Savings, 200.00, 2026-09-26, no
Rainy-day pot, Savings, 150.00, 2026-09-26, no
```
## Still to pay
view: bills as list columns item, amount, due sort due filter not paid sum amount plain
## The plan
What each category may take this month. A row in red has gone over.
```data plan as table plain sum planned, billed, left when left < 0 -> red
category, planned:number, billed = sum(bills.amount), spent = sum(bills.cleared), still to pay = sum(bills.unpaid), left = planned - sum(bills.amount)
Home, 1480.00
Food, 480.00
Transport, 260.00
Fun, 150.00
Savings, 350.00
```
## The boiler fund
The boiler is fourteen years old. The quote for a new one came in August.
```calc
boiler quote £2,850 =
saved by August £1,250 =
still to save = boiler quote - saved by August =
months to go = still to save / £200 =
```
Eight more payments of £200 make [calc 8 * £200], so the new boiler goes in next May.
## How it's made
- Every bill is one line of the `bills` data block. Its first line types the columns: `amount:number` adds up to the cent, `due:date` sorts as a date and `paid:bool` is a box to tick.
- `category:choice(from plan.category)` ties each bill to a line of the plan. There, `billed = sum(bills.amount)` adds up that category's bills, and `left = planned - sum(bills.amount)` is what remains.
- The tiles at the top are `view: plan as stats sum spent, "still to pay", left plain`. The chart under them reads the same rows: `as chart hbar by category sum planned, billed`.
- The boiler fund is a `calc` block. A line that ends in `=` shows its result, and a name on the left keeps it for the lines below.
## Try it yourself
1. Tick paid for Energy. "spent" rises by 96.40 and "still to pay" drops by the same.
2. In the plan, change Fun from 150.00 to 200.00. Its row is no longer red, and "left" grows by 50.
3. Add a bill `Window cleaner, Home, 18.00, 2026-09-20, no`. It joins Home, and the Home bar grows.
4. In the boiler fund, change `/ £200` to `/ £250`. The months to go drop from 8 to 6.4.
Next: *Invoices* totals line items per client. *Sales dashboard* draws its tiles and charts from a list of orders.