Skip to content

Line References

Refer to the value of any earlier line by its line number. References stay correct as you insert or delete lines: the numbers are renumbered live.

Use line<N> or the short form l<N>. The keyword is case-insensitive, so line1, LINE1, Line1, l1, and L1 all refer to the same line.

Notes Calculator
Calculation example
CalculationResult
4242
line142
L142

Line references behave like any other value: combine them with operators, units, currencies, and other references.

Notes Calculator
Calculation example
CalculationResult
1010
55
line1 + line215
line1 * 220

A reference adopts the value type of the line it points to. If line 1 is an amount with units or a currency, the reference renders the same way:

Notes Calculator
Calculation example
CalculationResult
5 miles5 mi
line1 + 16 mi

Write two line numbers with three dots between them to use a block of lines: line2...line5, the short form l2...l5, or just 2...5. On its own, a range adds up the lines, first and last included:

# Groceries |
12.50 | 12.50
8.20 | 8.20
|
4.30 | 4.30
line2...line5 | 25
2...5 | 25

Blank lines, headings, text and earlier total lines inside the range are skipped. The order doesn’t matter: l5...l2 is the same as l2...l5. Amounts with units and currencies add up the same way as with +:

Notes Calculator
Calculation example
CalculationResult
1 hour1 hour
45 min45 minutes
2 hours2 hours
1...33 hours 45 min

Inside a function, a range is the list of its values, so you can mix it with other arguments:

Notes Calculator
Calculation example
CalculationResult
1010
2020
3030
4040
avg(1...4)25
max(line1...line4, 50)50
sum(l1...l3)60
median(1...4)25

This works with sum, avg, min, max, median and stddev (see multi-argument functions).

Only three dots make a range (the … character works too). Two dots (line2..line5) and a colon (2:5) aren’t ranges, so those lines stay blank.

Editing any line inside the range updates the result.

Inserting a line above a reference or deleting a line shifts the numbers automatically: the text line1 is rewritten to line2 (and vice versa) so that the reference keeps pointing at the same logical line. Ranges are renumbered the same way.

Results that depend on a referenced line, such as total, prev or a variable defined from it, update as soon as you edit that line.

A line that references itself, references a line that doesn’t exist, or references a line that hasn’t been parsed yet resolves to NaN rather than raising an error. Arithmetic with a NaN reference also yields NaN.

Notes Calculator
Calculation example
CalculationResult
line5
line2

Only the bare line<N> and l<N> forms are recognised. The parser will not match references that are run together with other identifiers or contain underscores:

  • line1foo: not a reference (would need a space)
  • linear: not a reference (it’s a longer identifier)
  • l_3: not a reference (underscores aren’t allowed)