Skip to main content

Calculation field

Compute a value from other fields, including fields of linked records. Write the calculation, preview it with a record, and choose the result format.

Written by Leo

A Calculation field works out its value from other fields in the same record, and from fields of linked records. The value updates when the fields it uses change. Calculation fields are meant to help you stop doing the math by hand, for example a total price, the days until a deadline, or a name built from several fields.

The Edit calculation window of the field Net operating income with the formula, the result, and the record list of Preview with

Note:

  • People can't edit the result. They see it in the record, but only the calculation changes it.

  • A calculation can't use itself. Circular references are rejected.

Who can use the calculation field?

  • The calculation field is available on all plans: Free, Plus, and Premium. See what each plan includes on our pricing page.

  • To add or change a field, you need Full access to the database app and a desktop or tablet.

Add a calculation field

  1. Open the database app and open the app menu. Its tooltip reads Follow, export and more….

  2. Select Customize record layout.

  3. Point at a block and click +, or type / in a text block.

  4. Under New field, select Calculation.

  5. Click the drag handle (⋮⋮) of the new field and select Edit field.

  6. Select Edit calculation.

Clicking + next to a field in the layout editor, typing Calcul, and selecting Calculation under New field, which adds an empty Calculation field

Write the calculation

The window Edit calculation shows an editor with the hint Your calculation. When the editor is focused, it reads Type '@' for variables…. Type @ to insert fields of the record, properties such as the record ID, and values of linked records. Learn more about the calculation syntax →

Clicking the drag handle of the Net operating income field, selecting Edit field, opening Edit calculation, and choosing the record Riverstone Eight in Preview with

Preview with a record

Use Preview with and Select a record to try the calculation on a real record. Type a name in Search for a record…. Below, the preview shows the result, the reason why the calculation fails, or No output if there's nothing to show.

Type shows the format of the result: None, Number, or Date. If the calculation returns a number or a date, you can switch the format here.

The Edit calculation window previewing the calculation with the record Riverstone Eight and showing the result and its type

Editor tools

  • Open in fullscreen makes the editor larger, and Exit fullscreen brings it back.

  • cmd/ctrl + F opens find and replace in the editor.

  • option/alt + click adds another cursor, so you can edit several places at once.

  • Discard all changes appears once you've changed something. It goes back to the calculation as it was when you opened the window.

  • Learn about calculations opens a post about the calculation field in the Tape community.

  • When you close the window, Tape saves your changes. In fullscreen, select Save to keep your changes or Cancel to drop them. If you leave fullscreen another way with unsaved changes, Tape asks Discard changes?.

Calculation field settings

In Edit field, you find:

  • Edit calculation: opens the editor.

  • Format: how the result is read. None shows it as text. If the calculation returns a number, you can also choose Number. If it returns a date, you can choose Date.

  • Number settings (with Format set to Number) or Date settings (with Format set to Date): options for showing the number or the date. Learn more about the number field → To show an amount together with a link or a button, set Format to None, return text, and format the number in the calculation. See an example →

  • Trigger automations and Trigger webhooks: decide whether a changed result starts automations and webhooks.

The Edit field menu of a calculation field with Edit calculation, Format, Number settings, Trigger automations, and Trigger webhooks

Calculation errors

If a calculation can't produce a value, the editor reports the reason. Some of them:

  • "The script returned an undefined result (undefined)"

  • "The result is not a valid number."

  • "The script ended in an infinite value (Infinity)"

  • "A circular dependency was detected" followed by the fields involved.

  • "The script was not processed in the required time"

  • "Syntax error" followed by the details.

The preview in Edit calculation shows these messages for the record you picked.

The Edit calculation window of the field Net operating income with a formula that ends in * (), and the preview for the record Riverstone Eight showing Syntax error: Unexpected token ')'

If a calculation runs too long, Tape stops it and marks the value as invalid. The field keeps its last value, or stays empty if it had none, and the preview shows "The script was not processed in the required time".

Learn more: The calculation field cheat sheets in the Tape community have many examples to copy:

FAQs

Can a calculation use fields of linked records?

Yes, a calculation can read fields of records linked through a relation, for example the sum of all line items. Learn more about calculation syntax →

Can I use a calculation as the title of a record?

Yes, you can set a calculation field as the primary field. Learn more about the primary field →

Can a calculation return a date?

Yes, once your calculation returns a date, you can set Format to Date.

Can I use the result in an automation?

Yes, automations can use the value of a calculation field, and Trigger automations lets a changed result start one. Learn more about automations →

Why is my calculation field empty?

The calculation may return a value Tape can't store, or it may have an error. Open Edit calculation and check the preview for the reason.

Are there other field types?

Yes! Database apps have fields for text, numbers, dates, members, files, relations, calculations, and more. See every field type in Intro to fields →

Still have more questions? Find answers and get help from community experts in the Tape community →.

Did this answer your question?