Intro to formulas
IN THIS ARTICLE
In a Notion database, you can add a formula property that lets you run all
kinds of calculations and functions based on other properties. You can
use formulas to manipulate existing data and arrive at many other helpful
values 🔮
Notion formulas can perform helpful calculations using your existing database properties,
built-ins, and functions.
Formula examples
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Let’s look at a few different ways to use formulas. If you’re ready to get started building your
own, jump to our instructions on creating a formula below →
Example 1: Project management
In this example, we’ll use three formulas to track the progress of projects.
You can explore and play with the formula setups for this example by duplicating
this page to your workspace!
Functions and built-ins
Goal Property name Formula
used
dateAdd() adds time to
the date. The unit
argument can be one of
Set a project’s due
dateAdd(Start the following: years ,
date as two weeks Due date
Date, 2, "week") quarters , months ,
after its start date
weeks , days , hours , or
minutes . In this case,
we’ll use weeks .
Mark a project as Overdue? if(and(now() > Due if() returns the first
overdue if the due Date, Status != value if the condition is
date has passed "Done"), "Overdue", true; otherwise, returns
and its status is "") the second value. This
not Done . allows for a conditional
if(and(now() > Due
outcome.
Mark a project as Date, Status !=
overdue in bold, "Done"), and() is a logical
red letters if the style("Overdue", operator. This allows to
due date has "red", "b"), "") evaluate multiple factors
passed and its as being true.
status is not
now() returns the
Done .
current date and time.
This allows to evaluate
where we stand now,
compared to the project
due date.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
> is a comparison
operator. This allows to
compare the condition of
due date being larger
than current date.
!= is a comparison
operator. This allows to
define the condition of
status not being equal to
Done .
style() adds styles and
colors to the text. Valid
formatting styles include
b (bold), u (underline),
i (italics), c (code), or
s (strikethrough). Valid
colors are gray , brown ,
orange , yellow , green ,
blue , purple , pink , and
red . Add _background to
colors to set background
colors. In this case, we’ll
apply bold and red .
Show the number Tasks length([Link]( length() returns the
of overdue tasks remaining [Link] != length of the text or list
associated with a "Done")) value. This allows for a
project count of remaining tasks.
map() returns the list
populated with the
results of calling the
expression on every item
in the input list. This looks
at the tasks database and
pulls in all applicable
tasks.
!= is a comparison
operator. This allows to
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
pull tasks whose current
status is not Done .
Example 2: Project brainstorming
In this example, we’ll use two formulas to brainstorm project ideas, calculate a priority score
for each of them, and count the number of upvotes each project receives.
You can explore and play with the formula setups for this example by duplicating
this page to your workspace! For another setup that uses the RICE framework,
check out this template.
Goal Property name Formula
Based off of the scores for Reach, Impact,
Reach * Impact *
Confidence, and Effort (RICE), calculate a Score (RICE)
Confidence / Effort
prioritization score
When someone clicks the upvote button,
count them toward the number of total votes Total votes length(Upvoted by)
and add their name to the database page
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
(Advanced) Example 3: Task management automation
In this example, we’ll use some formulas in a database automation (another kind of database
property) to make it easier to manage projects and tasks as they’re completed by marking a
parent task as Done when all its subtasks are Done .
Database automations have triggers and actions that are taken based on those triggers.
Formulas allow you to define variables that you can then use in your actions.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
You can explore and play with the formula setups for this example by duplicating
this page to your workspace!
Goal How to build it Functions and built-ins used
Every time a task is set
Trigger: When
to Done , trigger the -
status set to Done
automation
Trigger page references the page in
the database the automation was
triggered from, and . allows you to
Action 1: Define
access properties associated with
Define the parent task Parent task
that page.
by finding the first page variable
related to the task that Parent item returns the contents
Formula: Trigger
triggered the from that property, which in this case
[Link]
automation is a list of related pages.
[Link]()
Applying the .first() function on the
Parent item property returns the first
related page from that list.
The ternary operator X ? Y : Z is a
shorthand conditional expression
that means: if the condition X is true,
return Y; otherwise, return Z. It's a
Action 2: Define
concise alternative to an if()
All subtasks done?
If the parent task has statement.
variable
subtasks, verify .every() checks whether a condition
whether all its subtasks Formula: Parent
is true for each item in a list. Within
have a status of Done . [Link]-item ?
this function, you can use the
If the parent task has no Parent [Link]-
keyword current to refer to the row
subtasks, return false . [Link]([Link]
being evaluated. In this case, the
atus == "Done") :
condition [Link] == "Done"
false
checks whether the current page’s
status property is set to Done . If so,
it will return true ; otherwise it will
return false .
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
If all subtasks are Action 3: Edit Again, the ternary operator is used
Done , set the parent Status property here to see if all subtasks are done. If
task’s status to Done . If Formula: All they are, the automation will set the
not, retain the existing subtasks done? ? parent task’s status as Done ; if not,
status of the parent "Done" : Parent it will keep the parent task’s status as
task. [Link] is.
More formula inspiration
This Notion template calculates the time between two dates with a formula
property.
This Notion template uses a formula to count upvotes for different ideas.
You can find even more example formulas here →
Where formulas can be used
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
In Notion, you can use formulas in a few different ways:
As a database property, which is what this article primarily covers.
In a button action.
In a database button action.
In a database automation action.
Create a formula
To create a formula database property:
1. Select the slider icon at the top of a database → Edit properties → New property .
2. Select Formula .
3. Give your property a name if you’d like.
4. Select Edit formula .
Edit a formula
Once you’ve created a formula in a database or button, you’ll be able to build and edit that
formula in the formula editor, which looks like this:
The field at the top is where you enter and edit your formula. As you write your formula at
the top of the editor, the editor will let you know what’s missing, or what the formula expects
in order to return a value to you.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
The panel on the left side of the edit shows the elements that you can use in the formula —
in other words, the properties, built-ins, and functions that are available to you.
The panel on the right side defines formula elements as you hover over them in the left
panel. It also gives you examples of how you might use those elements and how they should
be structured.
If you open the formula editor from a database row, you'll see a live preview of the result of
the formula for that row.
Having trouble with your formula? Learn about common formula errors and how
to troubleshoot them in this article→
Create and edit formulas with Notion AI
Note: This feature is only available on the Business or Enterprise Plan.
Know what you want your formula to do, but not quite sure how to build it? Want to make
some tweaks to an existing formula? See an error in your formula, but don’t know how to fix
it? Notion AI can help.
When you’re in the formula editor, you’ll see a field containing the Notion AI face. Click into
this field and tell Notion AI what you want your formula to do, or ask questions about the
formula to understand it better.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Here are some example prompts you can give Notion AI:
“Turn the title property into a URL slug.”
“Return ⚠️if the due date has passed.”
“Add one day to the date property and make the output green and bold.”
“Return the date property from the related database” (Notion AI knows about your
relations’ properties too!)
“Italicize the output of this formula.”
“Fix the errors in this formula.”
“Make this formula handle edge cases.” (For example, Notion AI could add an if statement
so that the formula doesn’t fail when a field is empty.)
“What does this formula do?”
Once you enter your prompt, Notion AI will generate a formula or respond to your query
about it. You can also see a preview of your formula output as well as toggle on Show types
to see the output type (for example, text), so you can make sure everything looks the way
you want. You can undo Notion AI's changes, give it further prompts, or give a thumbs up or
thumbs down to let us know how it did.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
When you’re creating and editing formulas using Notion AI, note that Notion AI currently
doesn’t support the following:
Iterative logic (like for loops).
Random generations that would require a random() function, which Notion formulas don’t
have. A prompt like “Generate a random number between 1 and 10” wouldn’t work.
Remembering previous prompts.
Notion AI can help you with formula properties as well as formulas inside buttons, database
buttons, and database automations.
What formulas are made of
Formulas can be created using a combination of:
Properties.
Built-ins, or operators and booleans that are used to set up a specific calculation. Some
examples include + (add), false , and or .
Functions, or actions that the formula can take to return a certain output. Some examples
include replace , sum , and sort .
A full list of the built-ins and functions that are available in formulas is available here →
Up next
Formula syntax & functions
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Notion formulas can operate on various properties and functions. Here, you'll find a list of
them ➗
Read more →
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF