Skip to content

Formula, lookup or rollup: which one does your math

One question sorts the three computed fields: where are the inputs? On the same record, use a formula. Across a link, a lookup. About a group, a rollup.

Updated November 2026

Every no-code database offers three fields that compute a value instead of storing one, and the menu never explains which one you need. One question sorts them every time:

Where are the inputs?

  • On the same record → formula.
  • On the other end of a link, and you want to see a value → lookup.
  • On the other end of a link, and you're asking about the group → rollup.

Below are examples of each answer, a decision table, and the mistakes each choice prevents.

Same-record math: formula

An order has a Total and a Discount. The amount to collect is arithmetic on the record in front of you:

{Total} * (1 - {Discount} / 100)

Both inputs are on the record, so no link is involved, and neither of the other two fields could even ask the question. Formulas handle math within one record, such as prices times quantities, the days between two of the record's own dates, text assembled from the record's own fields, or an IF on its own status.

You need more than a formula when it wants a value the record doesn't have. "The customer's email" isn't on the order. It's across a link, so add a lookup for it first, and then a formula can read the lookup.

Each order links to one customer. To show the customer's email on the order, nothing needs computing. The value already exists on the linked record, and copying it would create a second version that can drift. A lookup shows it without copying it. The email stays on the customer record, every order shows it, and one edit updates all of them.

Lookups answer "show me the linked record's X." They're read-only where they appear, because the value is kept in one place.

A question about the group: rollup

A customer links to many orders. "What has Nour spent?" isn't any single order's value. It's a fact about the collection, the sum of the linked orders' totals. That's a rollup, where you pick the link, the field and the operation. Other rollups give you the count of linked plants, the latest delivery date across lines, or the average order value.

Lookup vs rollup goes through this boundary in more detail, and its test is this: if deleting one linked record should change the value, it's a rollup. Deleting an order changes Nour's total, so that's a rollup. It doesn't change her email, so that's a lookup.

The decision table

I want Use
Amount to collect, from this order's total and discount Formula
Days between this record's two dates Formula
"GUEST-" + the record's number, as a reference code Formula
The customer's email, shown on each order Lookup
The supplier's phone, shown on each product Lookup
How many plants this order holds Rollup (count)
What this customer has spent across all orders Rollup (sum)
The latest delivery date across this order's lines Rollup (max)
Average order value per customer Rollup (average)
The price you charged, on the day you charged it None (store it)

That last row is the standing exception. A fact about a past event must not recompute when today's inputs change. A derived field always shows today's answer, so type the invoice price in once.

Common mistakes

Maintaining a derived value by hand. Someone keeps a Total spent field and updates it when they remember. It's wrong within a month, and nobody has to be careless for that to happen, because nothing marks it as stale when an order changes. Every derived field on this page computes that kind of number from what's true now, with no sync step to forget.

A lookup pointed at the many side. Say you want "the order total" on a customer who has thirty orders. A lookup through that link shows thirty values, because there are thirty answers. What you wanted was one number about the thirty, and that's a rollup. Use a lookup for one → one and a rollup for one → many.

A formula doing a lookup's job. A formula reads what is on its own record, and that includes most lookups and rollups, such as {Customer email} or {Total spent}, worked out fresh on every read. To use a value from across a link, add the lookup or rollup first, then point the formula at it.

Deriving what must not change. The invoice priced from a lookup of the current price list reprices history the day the list changes. See the last table row.

How this works in Tabla

Tabla has all three fields under these names, and it enforces the shapes above instead of only suggesting them:

  • A formula is computed by the database itself, as a generated column, so it can't drift from its inputs. It reads the record's own fields, including lookups, rollups and links, and works out to a number, text, a date or a yes/no. Anything it can't read is refused when you write the expression, instead of turning up as a problem later. A formula that uses the clock, such as TODAY() or NOW(), has no stored column to go stale. It's worked out fresh on every read, and it still filters and sorts like any other field. So does a formula that reads a lookup, a rollup or a link, and it can have a summary under the grid too.

About Tabla

Tabla is a no-code database with Postgres underneath. Every feature is on every plan, you get a million records per database, and you can export your whole database in one file any day.

More guides