Formulas with relations: reading another database
A relation links pages in one database to pages in another, like Projects ↔ Tasks. In Formulas 2.0, prop("Tasks") gives you a list of pages, and you can read any property of those pages directly. For many jobs you no longer need a rollup.
The pattern: current.prop()
prop("Tasks").map(current.prop("Hours")).sum() → total hours
prop("Tasks").filter(current.prop("Done")).length() → number of done tasks
prop("Tasks").map(current.prop("Name")).join(", ") → names as text
Inside map() and filter(), current is the related page being looked at.
Setup checklist
- Create a Relation property pointing at the other database. Turn on "Show on [other database]" if you want the link both ways.
- Link a few pages so the formula has data.
- Add a Formula property and start with
prop("Tasks")to see the list, then chain from there.
Rollup or formula?
A rollup is quicker for one simple number, like a sum or count. A formula is better when you need a condition, like summing only open tasks. It also lets you combine several related properties in one place.