# What is a Notion Formula?

Learn the definition of a Notion formula and what formulas can do in your databases.

Notion formulas are bits of code that can make your Notion databases much more useful.

Formulas in Notion are like a limited programming language. They’re written and used in Formula properties within Notion databases (learn more about databases with my complete beginner’s guide).

Formulas can take in data from all other database properties, process it using constants, operators, and built-in functions, and then output new data.

Using formulas, you can do things in your Notion databases that are otherwise impossible.

This site is a comprehensive reference for creating, using, and debugging Notion formulas.
You can read more about it – and how to use it – in the Reference Introduction.

Every formula constant, operator, and function has been fully documented with example code and one or more working example databases, complete with templates you can duplicate.

You’ll also find reference guides on things like operator precedencedata type conversiondebugging, and regular expressions.

Let’s say you’re a sales manager with several existing clients. You want to make sure you check in with each client every three months.

Notion formulas will let you create a database view like this (assume “today” is August 18, 2022 – the day I wrote this guide):

View and duplicate this example:

Not only is your Next Check-In date automatically calculated based on your Last Check-In, but the view is also grouped (using Notion’s grouping feature) so that you can easily see any check-ins that need to happen within the next seven days.

Two formulas power this database view: Next Check-In and Next 7 Days.

The Next Check-In formula looks at the date set in the Last Check-In property and calculates the next date by adding three months. To accomplish this, it uses the dateAdd function.

.wp-block-code {
border: 0;
}

.wp-block-code > div {
overflow: auto;
}

.shcb-language {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
position: absolute;
width: 1px;
word-wrap: normal;
word-break: normal;
}

.hljs {
box-sizing: border-box;
}

.hljs.shcb-code-table {
display: table;
width: 100%;
}

.hljs.shcb-code-table > .shcb-loc {
color: inherit;
display: table-row;
width: 100%;
}

.hljs.shcb-code-table .shcb-loc > span {
display: table-cell;
}

.wp-block-code code.hljs:not(.shcb-wrap-lines) {
white-space: pre;
}

.wp-block-code code.hljs.shcb-wrap-lines {
white-space: pre-wrap;
}

.hljs.shcb-line-numbers {
border-spacing: 0;
counter-reset: line;
}

.hljs.shcb-line-numbers > .shcb-loc {
counter-increment: line;
}

.hljs.shcb-line-numbers .shcb-loc > span {
}

.hljs.shcb-line-numbers .shcb-loc::before {
border-right: 1px solid #ddd;
content: counter(line);
display: table-cell;
text-align: right;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
width: 1%;
}
dateAdd(prop("Last Check-In"), 3, "months")


The Next 7 Days formula is slightly more complex. Using the if function, it uses branching logic to output one of two different strings.

If the date displayed in Next Check-In is less than eight days away (from today’s date), then the formula outputs, “Next 7 Days”.

Otherwise, it outputs, “More than 7 Days Out”.

To determine how far out the Next Check-In date is, we use the dateBetween function as the first argument in our if-statement.

// Compressed
if(dateBetween(prop("Next Check-In"), now(), "days") < 8, "Next 7 Days", "More than 7 Days Out")

// Expanded
if(
dateBetween(
prop("Next Check-In"),
now(),
"days"
) < 8,
"Next 7 Days",
"More than 7 Days Out"
)


Now that we have a formula which can output two different strings of text, we use them in this database view’s Group By setting:

Throughout this reference, I’ll mention many different terms related to Notion formulas. Here are a few of the most important terms and what they mean.

I use the term “components” to collectively refer to the following tools that you have at your disposal when constructing formulas:

• Properties – these are the other properties that exist in your database.
• Constants – the mathematical constants $$e$$ and $$π$$, plus the Boolean values true and false.
• Operators – symbols that perform operations on 1-3 operands. Includes mathematical operators (such as add), Boolean operators (such as not), and the ternary operator (if).
• Functions – pre-defined formulas that you can use to accomplish complex things quickly. Examples include concat (combines strings) and dateAdd (adds x unites of time to a date).

Notion formulas work with – and output – one of four different data types:

Understanding data types is crucial for comfortably working with Notion formulas. Every property outputs a specific data type (except Formulas and Rollups, which can output several).

Additionally, every operator and function accepts specific data types in its argument(s). They also output data of a specific type – and that type is often different than the data types taken as inputs.

You can see an example of every property type within Notion referenced in a formula in this database:

Data Type Example

Here’s an example using the dateAdd function:

dateAdd(now(),5,"days")


This function requires three arguments, which must be (in this order):

1. A date
2. A number
3. A string (this must also be one of the accepted units, such as “days” or “years”)

If the arguments are not passed data of the correct type, the formula will throw a Type Mismatch error.

Good to know: Unlike many programming languages, Notion does not do automatic type conversion within formulas. You’ll need to provide data of the correct type within all function arguments.

The only exceptions to this are the test, replace, and replaceAll functions. These are advanced functions, so I won’t cover their details here.
You’ll also need to make sure the final output of your formula has only one data type.