Skip to main content

Intro to Formulas

Inside any Closot database, you can add a Formula property that performs calculations, evaluates conditions, and produces dynamic outputs based on the values of other properties in the same database. Formulas unlock a layer of intelligence on top of your raw data — turning a static table into something that thinks alongside you.


What You Can Build with Formulas

Formulas aren't limited to simple arithmetic. The same formula engine powers everything from basic date math to complex conditional logic used inside automations. Here are three real-world examples to illustrate the range of what's possible.

Image


Example 1 — Deadline & Status Tracking

Imagine a product launch database where each item has a Start Date, a Status, and a set of linked tasks. Three formulas working together can make this database self-monitoring:

1. Calculate a Due Date from Start Date

dateAdd(Start Date, 2, "week")

The dateAdd() function takes a date, adds a quantity, and returns the new date. Supported units: "years", "quarters", "months", "weeks", "days", "hours", "minutes".

2. Flag Overdue Items Automatically

if(and(now() > Due Date, Status != "Done"), "Overdue", "")

This formula evaluates two conditions simultaneously using and() — whether the current time has passed the due date, and whether the item isn't already marked done. If both are true, it outputs "Overdue". Otherwise it returns an empty string and stays invisible.

Want to make the overdue label visually pop? Use style() to add color and formatting:

if(and(now() > Due Date, Status != "Done"), style("Overdue", "red", "b"), "")

style() formatting options:

CodeEffect
bBold
uUnderline
iItalic
cCode
sStrikethrough

Valid colors: gray, brown, orange, yellow, green, blue, purple, pink, red

Append _background to any color to apply it as a background instead of text color — e.g., "red_background".

3. Count Linked Tasks

Tasks.length()

length() returns the number of items in a list. When applied to a Relation property, it counts how many related pages are linked.


Example 2 — Prioritization Scoring

A product backlog database where features compete for attention. Two formulas turn vague gut-feel prioritization into a data-driven ranking:

1. RICE Score

Reach * Impact * Confidence / Effort

A standard prioritization framework expressed as a single formula — multiply Reach, Impact, and Confidence, then divide by Effort. Sort the database by this formula to surface the highest-value, lowest-effort items instantly.

2. Count Upvotes from a Collaborator Property

length(Upvoted by)

If you have a Person property where teammates vote by adding their name, length() counts the total number of voters — giving you a live tally without any manual tracking.


Example 3 — Advanced Automation Logic

Formulas can also power database automations — letting you build conditional workflows that respond to changes automatically. This example automatically marks a parent task as "Done" when all its sub-tasks are complete.

1. Retrieve the Parent Task

Trigger page.Parent item.first()
  • Trigger page — references the database item that triggered the automation
  • .Parent item — accesses the "Parent item" relation property on that page
  • .first() — returns the first (and typically only) related parent page

2. Check Whether All Sub-tasks Are Done

Parent Task.Sub-item ? Parent Task.Sub-item.every(current.Status == "Done") : false

This uses the ternary operator X ? Y : Z:

  • If Parent Task.Sub-item has any items, evaluate .every() — which returns true only if every item in the list satisfies the condition
  • If there are no sub-items at all, default to false
  • current refers to the item currently being evaluated inside the loop

3. Determine the Status to Set on the Parent

All subtasks done? ? "Done" : Parent Task.Status

If the "All subtasks done?" formula property evaluates to true, set the parent's status to "Done". Otherwise leave the parent's status unchanged.


Image

Where Formulas Work

Formulas aren't limited to formula properties inside databases. You can use them in:

  • Database formula properties — the most common use case
  • Button actions — trigger calculated outputs from a button click
  • Database button actions — buttons embedded inside database views
  • Database automation actions — conditions and values set by formula logic

Create a Formula Property

  1. Click the slider icon at the top of your database
  2. Click Edit propertiesNew property
  3. Select Formula as the property type
  4. Optionally name the property
  5. Click Edit formula to open the formula editor

The Formula Editor

The editor has three zones:

  • Top input field — type or paste your formula here
  • Left panel — browse available database properties, built-in operators, and functions
  • Right panel — documentation panel showing definitions and examples for whatever you've selected
  • Live preview — visible when the editor is opened from inside a database row; shows the formula output for that specific item in real time

What a Formula Can Contain

Every formula is built from some combination of three components:

ComponentWhat it isExamples
PropertiesReferences to other database fieldsprop("Due Date"), prop("Assignee")
Built-insOperators and boolean values+, -, *, /, true, false, and, or
FunctionsNamed operations that return a computed valueif(), dateAdd(), replace(), sum(), sort()

For the complete list of supported properties, built-ins, and functions — including parameters, return types, and syntax examples — see Formula syntax & functions.