SelfscribeDownloadOpen the app

Household budget

Every bill in one table, added up to the cent, with a chart and a list of what is still to pay.

Interactive · Simple · uses totals, chart, table

Edit it in the playgroundRead the file

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.
examples/budget.self · 118 lines
~~~ 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.