CommunityHire an ExpertSign Up
DatabasesLinked records, lookups and rollups
Tables and fields

Linked records, lookups and rollups in Softr Databases

Connect tables with related record fields, show data from linked records with lookups, and count or total it with rollups. Steps and formulas for each field.

Related record, lookup and rollup fields connect the tables of a database. A related record field links a record to records of another table. A lookup shows a value from the linked record. A rollup counts or totals values across linked records.

The Projects table, with four fields outlined: Client and Invoices are related record fields, Client phone is a lookup of the client's phone, and Total invoiced is a rollup that adds up the invoices

FieldWhat it doesUse it to
Related recordConnects records between two tablesAssign tasks to employees, or projects to clients
LookupShows a field of the linked recordShow a client’s phone number in the projects table
RollupAggregates a field across linked recordsTotal the invoices of a project, or count its open tasks

A related record field (also called a relationship field) connects a record in one table to records in another. Use it instead of copying the same data into both tables.

  1. Open your database and select the table that gets the field.
  2. Select Add field at the end of the table header.
  3. Select Related record as the field type.
  4. Choose the Related table to link to. For example, link a “Projects” table to a “Clients” table.
  5. Turn Allow linking to multiple records on or off in the field of each table. The two settings decide whether the relationship is one-to-one, one-to-many or many-to-many.
  6. Name the field and select Save.

Softr creates the matching related record field in the linked table. A change in one table shows in the other.

The field editor of the Client field: Field type Related record, with Related table set to Clients and Allow linking to multiple records off, both outlined. Below are Selectable records and Default record

For example, a related record field in “Tasks” assigns each task to a person from “Users”. Each task then shows its employee, and each employee shows all their tasks.

Lookup fields

A lookup field shows a field of a linked record, so you don’t copy the data by hand. It needs a related record field first.

Set up a lookup field

  1. In the table with the related record field, select Add field.
  2. Select Lookup as the field type.
  3. Under Look up value for related…, choose the related record field that connects to the other table.
  4. Under Field to look up, choose the field of the linked table to show, such as “Phone”.
  5. If the related field links several records, open Record Options to Sort or Filter the linked records. Turn on Limit number of records and set the Maximum number of records to show only the first ones.
  6. Name the field and select Save.

The field editor of the Client phone field: Field type Lookup, the related field Client, and Field to look up set to Phone, outlined

A lookup field is read-only and updates when the source data changes. For example, a lookup in “Projects” shows each client’s phone number next to the project details.

Rollup fields

A rollup field aggregates a field across linked records with a formula. It needs a related record field first.

Set up a rollup field

  1. In the table with the related record field, select Add field.
  2. Select Rollup as the field type.
  3. Under Related records to roll up from, choose the related record field.
  4. Under the next setting (‘Invoices’ field to roll up for an Invoices field), choose the field of the linked table to aggregate, such as “Amount”.
  5. Under Aggregation formula, choose how to combine the values.
  6. Name the field and select Save.

The field editor of the Total invoiced field: Field type Rollup, rolling up the Amount field of the related Invoices, with Aggregation formula set to SUM, outlined

These are the aggregation formulas:

FormulaWhat it returns
MINThe lowest numeric value
MAXThe highest numeric value
SUMThe total of the numeric values
AVERAGEThe average of the numeric values
COUNTThe number of non-empty numeric values
COUNTAThe number of non-empty text or numeric values
COUNTALLThe number of all values, including empty ones
ARRAYJOINAll elements joined into one string, separated by semicolons, for example [1, 2] becomes “1; 2”
ARRAYUNIQUEThe values without duplicates, keeping the first of each
ARRAYCOMPACTThe values without blank or empty elements
ARRAYFLATTENNested lists made into one list, for example [[1], [2, 3]] becomes [1, 2, 3]

For example, a rollup in “Projects” with SUM on the “Invoice amount” of linked invoices shows the total invoiced for each project. A rollup updates when the linked records change.

  • Name tables after things. Think about the nouns of your app (Clients, Projects, Invoices) and keep adjectives for fields such as Category, Type or Status.
  • Name link fields clearly. For example, “Client name” or “Total invoiced”.
  • Check rollup results. Test complex aggregations on a few records.
  • Keep lookups and rollups few. Too many can slow down your database, so add only what your app shows.

Troubleshooting

ProblemWhat to check
A related record field shows no recordsBoth tables are in the same database, and the field is set up correctly
A lookup field is blankThe related record field has linked records, and the field you look up has data
A rollup field shows errorsThe formula suits the data, for example numbers for SUM, MIN and MAX

FAQ

Can I edit the value of a lookup or a rollup?

No. Lookup and rollup fields are read-only. They update by themselves when the linked records change. To change the value, edit the field in the linked record.

Why does my lookup show several values?

A lookup shows the field of every linked record. If the related record field links three invoices, the lookup shows three values. To show fewer, turn on Limit number of records in the lookup settings. To show one result, such as a total or a count, use a rollup instead.

Can a lookup show data from a table in another database?

No. A related record field links tables of the same database, and lookups and rollups follow that link. To use data from another database, import or copy it into this database, or link the records with a workflow.

Use these docs with your AI tools

An AI agent can read this documentation directly. You do not need an account or an API key. Everything here is public and read-only.

Query these docs via MCP

Recommended

Add this server to Claude, Claude Code, Cursor, Mistral, or any tool that supports MCP. Your agent can then search Softr Documentation documentation and read it in full, instead of answering from memory.

https://docs.softr.io/mcp
  • searchFind the passages that answer a question.
  • fetchRead one page in full, as Markdown.
  • list_pagesSee every page in this documentation.

Query these docs over HTTP

The same tools also work as plain web requests. Use this for scripts, or for any tool that does not support MCP. There is one endpoint per tool. Arguments go in the query string, and the answer comes back as JSON.

https://docs.softr.io/api/docs/search?query=custom+domain

Read the OpenAPI description. It is built from the same definitions as the tools, so it always matches what the endpoints do.

Read these docs as Markdown

Add .md to any page URL to get its Markdown source. You can also send the headerAccept: text/markdown to the page URL itself.

To read the whole documentation in one file, open llms-full.txt. For a short index of every page, open llms.txt.