Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 36 ยท Relations and Formulas

Formula Basics

Start with Notion formulas: read properties with prop(), do math, join text, make decisions with if() and ifs(), and understand the result types.

A formula property computes a value for each row from that row's other properties. It updates automatically, so it never goes stale. Formulas turn a database from storage into logic: totals, labels, flags, countdowns.

Notion's current formula language ("Formulas 2.0") uses a function-and-dot syntax and an editor with autocomplete. Examples here follow that syntax. The formula editor is not available on this page, so the runnable code blocks are stand-ins written in JavaScript: they mirror what the Notion formula would compute, but they are not the Notion language itself.

Creating a formula property

Add a property, choose Formula, and type into the editor. A preview shows the result for the first row, and errors are highlighted. Click Done to save.

Reading properties

Use prop("Name") with the exact property name in quotes:

TEXT
prop("Price") * prop("Quantity")

Types matter:

Property type prop() returns
Number number
Text, Select text
Checkbox boolean
Date date
Multi-select, Relation, Person list

A formula in three steps

Read prop("Name") brings in a value.
Compute Math, text and logic.
Return One value per row.
1 / 2

Math and text

Operators work as expected: + - * / % and ^ for power. Parentheses group. Text joins with +:

TEXT
prop("First name") + " " + prop("Last name")

Numbers must be converted to text before joining: format(prop("Price")) (or prop("Price").format()). For the opposite direction, toNumber("42"). Common numeric helpers are round(), floor(), ceil(), abs(), min(), max() and sqrt().

TEXT
round(prop("Price") * prop("Quantity") * 1.2 * 100) / 100

Decisions: if() and ifs()

if(condition, then, else) returns one of two values:

TEXT
if(prop("Quantity") > 100, "Bulk", "Standard")

ifs() handles several tests in order and ends with a default:

TEXT
ifs(prop("Score") >= 90, "A", prop("Score") >= 80, "B", prop("Score") >= 70, "C", "Needs work")

Combine conditions with and, or and not (or &&, ||, !). Compare with == and !=. An empty check is empty(prop("Due")).

Common first formulas

  • Total: prop("Price") * prop("Qty")
  • Flag: if(prop("Priority") == "High" and not prop("Done"), "Act now", "")
  • Full name: prop("First") + " " + prop("Last")
  • Progress message: format(prop("Done tasks")) + " of " + format(prop("All tasks"))

If a formula shows an error, read the message under the editor: it names the line, a type mismatch (for example, adding a number to text) or a property that does not exist. Fix types with format() and toNumber().

Stand-in: evaluating the idea

The code below imitates formulas using plain JavaScript functions over a row. It shows the logic of prop, if and ifs as data flow.

JS Row formulas as functions (stand-in)

Press Run (or Ctrl + Enter) to see the console output here.

No output.

JS ifs(): first matching test wins (stand-in)

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Mistakes to avoid

  1. Misspelling a property name; prop("price") and prop("Price") differ.
  2. Mixing types: "Total: " + prop("Price") fails; use format().
  3. Formatting numbers by multiplying and rounding in the formula when the property's own Number format would do.
  4. Forgetting a default in ifs(), so unmatched rows return nothing useful.
  5. Hard-coding values such as tax rates. Put them in a database property so one change updates all rows.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How do you read a property named Price in a formula?

    prop("Name") reads the row's property with that exact name.
  2. 2. What is wrong with joining text and a number, as in a Total label plus prop(Price)?

    Joining text and numbers needs an explicit conversion such as format().
  3. 3. What does ifs() do?

    It is a chain of if tests with a final default value.
  4. 4. Which operator checks equality in a Notion formula?

    Use == (and != for not equal).

Summary

  • A formula property computes a per-row value from other properties.
  • Read values with prop("Name"); convert with format() and toNumber().
  • Use if() and ifs() for decisions, with and, or, not.
  • Keep constants in properties, not inside formulas.

Next: Formula Functions and Dates