Skip to content

Relations and rollups

A Relation links rows in one database to rows in another. A Rollup then reads the linked rows and works out a value from them, like a count or a total.

For example, with a Projects database and a Tasks database:

Projects Tasks
┌──────────────┬──────────┐ ┌───────────────┬───────────┬──────────┐
│ Name │ Tasks │ ◄──► │ Name │ Project │ Estimate │
├──────────────┼──────────┤ ├───────────────┼───────────┼──────────┤
│ Website │ 3 tasks │ │ Write copy │ Website │ 2 │
│ Launch │ 1 task │ │ Pick fonts │ Website │ 1 │
└──────────────┴──────────┘ │ Build pages │ Website │ 5 │
│ Press release │ Launch │ 3 │
└───────────────┴───────────┴──────────┘

A relation called Tasks on Projects links each project to its tasks. A rollup on Projects can then add up each project’s Estimate: 8 for Website and 3 for Launch.

  1. Add a property and pick Relation.
  2. Under Relation to…, pick a database. Type in Search databases to find it. The database you’re in is marked This database.
  3. Leave Show on the other database on to add a matching relation to the other database too, or turn it off for a one-way relation.

The relation’s panel then shows which database it’s Related to, and whether it’s Shown on both databases or Shown on this database only.

Two-way One-way
Where it shows On both databases Only on the database you added it to
The other side A matching relation named after this database. Linking a task to a project also lists the task under the project Nothing. The other database doesn’t know about the link
When to use it Most of the time When the other database shouldn’t change, or would get too many properties

A relation from a database to itself, made in the app, is always one-way.

You can only relate databases in the same organization. If the other database already has 300 properties, Lyra asks you to make the relation one-way instead.

Click a relation cell to open Search for a page…. It lists rows from the related database. Click a row to link it, and click it again to unlink it. With a two-way relation, the other database’s cell changes too.

Linked rows show as chips in the cell. Click a chip to open that row.

You see the titles of linked rows only if you can open the related database. Rows you can’t open show as No access.

A rollup needs a relation on the same database.

  1. Add a property and pick Rollup.
  2. Under Relation, pick the relation to read through.
  3. Under Property, pick the property of the linked rows to read.
  4. Under Calculate, pick what to work out.
  5. Click Create rollup.

To change a rollup later, click its header, pick Edit property and click Save when you’re done.

If the database has no relation yet, the panel says Add a relation first, then roll up its values.

Calculate What it shows Works on
Show original The linked rows’ values, joined with commas Any property
Count all How many rows are linked Any property
Count values How many linked rows have a value Any property
Count unique values How many different values there are Any property
Count empty, Count not empty How many linked rows have no value, or have one Any property
Percent empty, Percent not empty The same as a percentage Any property
Sum, Average, Median, Range The total, the average, the middle value, or the largest minus the smallest Number properties and formulas or rollups that give numbers
Min, Max The smallest or largest value Numbers or dates
Earliest date, Latest date The first or last date Dates
Checked, Unchecked How many linked rows have the box checked, or not Checkbox
Percent checked The share of linked rows with the box checked Checkbox

Linked rows in the trash don’t count.

A rollup can read a formula from the linked rows, but not another rollup.

Rollups work out their values inside the database, so you can filter and sort on them. A Show original rollup is the exception: it can’t be filtered.

A formula can use a rollup with prop("Name"). To work with the linked rows themselves in a formula, use the relation and list functions instead:

prop("Tasks").filter(current.prop("Status") == "Done").length()
Message Why
Rollup 'Name' needs a number property for that function Sum, Average, Median and Range need numbers. Pick a number property or another calculation
Rollup 'Name' needs a date property for earliest (or for latest) Earliest date and Latest date need dates
Rollup 'Name' has no relation The relation it reads through was deleted. Edit the rollup and pick another
Rollup 'Name' points at a property that no longer exists The property it reads on the linked rows was deleted. Edit the rollup and pick another
  • Formulas: work with linked rows in a formula
  • Views: filter and sort on rollups