if
Learn how to use the "if" operator in Notion formulas.
The `if()` operator allows you to write if-then statements within a Notion formula.
1
if([condition], ['then' expression], ['else' expression])
2
3
// Argument 1 must always return a Boolean value.
4
// Arguments 2 and 3 must have a matching type.
5
if(Boolean, string, string)
6
if(Boolean, number, number)
7
if(Boolean, Boolean, Boolean)
8
if(Boolean, date, date)
If-then statements, also called conditional statements, contain:
• The condition - a statement to be evaluated for truthiness (i.e. “is it true?”)
• The “then” statement - a statement that is executed if the condition is true
• The “else” statement - a statement that is executed if the condition is false
`if()` looks like a function in Notion, but it’s actually considered an operator because an if-then statement can be written with ? and : instead of the `if()` syntax.

# Example Formulas

## Simple String Comparison

This formula compares the output of a Select property called Type (which has a data type of String) with the string value “Mammal”. If the two are equal, it outputs true; otherwise, false.
1
if(prop("Type")=="Mammal",true,false)

### Shorthand Syntax

If-then statements can also be written in a shorthand syntax. This uses `?` and `:` as shorthand for `if()`.
• Everything left of the `?` is the statement being evaluated.
• Between `?` and `:` is the output if the evaluated statement is true.
• Right of the `:` is the output if the evaluated statement is false.
1
[condition] ? ['then' statement] : ['else' statement]
Here’s our example formula from above, re-written using shorthand:
1
prop("Type")=="Mammal" ? true : false
Taken together, `?` and `:` form what’s called the conditional (or ternary) operator. It’s the only operator that takes in three operands, which are objects that are being operated on.
Most operators only work with two operands - for example:
• `2 + 5` - the add (`+`) operator is working on `2` and `5`
Check out the two formula properties in this example database; one uses the normal if-then syntax, while the other uses shorthand. You’ll see that their output is the same.

## View and Duplicate Database

if
College Info Geek on Notion
Other formula components used in this example:

## Nested If-Then Statements

Writing nested if-statements can become difficult in Notion’s default formula editor. If you’re writing a long formula, I recommend writing it in a free code editor such as VS Code, and then minifying it using Excel Formula Beautifier so it can be pasted into Notion (remove the = sign at the beginning of the formula output if it exists before pasting).
Notion does not support the “else if” statement that is support by more popular scripting and programming languages, such as Javascript.
With an else if statement, you could write code like this (in Javascript):
1
/* This is Javascript code that won't work in a Notion formula */
2
3
if (x<13) {
4
/* do one thing */
5
} else if (x<19) {
6
/* do another thing */
7
} else {
8
/* do the last thing */
9
}
In Notion, what we have to do instead is create nested if-then statements, like so:
1
if(
2
prop("Age") < 13,
3
"Child",
4
if(
5
prop("Age") < 19,
6
"Teenager",
7
8
)
9
)
• If the numeric value of a row’s Age property is less than 13, the then portion of the if-then statement is executed and the formula returns `Child`.
• If not, the else statement is executed. In this case, our else statement is yet another if-then statement - hence, it’s a nested if-then statement.
• Within the nested statement, the same logic applies. The condition is tested; if Age is less than 19, the then statement executes and outputs `Teenager`. If not, the else statement is executed and outputs `Adult`.
Here’s the logic tree for this nested if-then statement:
Here’s a compressed version you can paste into a Notion formula property:
1
// if() syntax
2
if( prop("Age") < 13, "Child", if( prop("Age") < 19, "Teenager", "Adult" ) )
3
4
// ? syntax
5
prop("Age") < 13 ? "Child" : prop("Age") < 19 ? "Teenager" : "Child"
6
// Notion will refrormat this to:
7
(prop("Age") < 13) ? "Child" : ((prop("Age") < 19) ? "Teenager" : "Child")
Good to know: As you can see in the code block above, you can create nested statements with the conditional operators `?` and `:` as well.
When using these, you don't even need to add your own parentheses `()` to create your nested statement; Notion will add them after you exit the formula editor.
In the example database below, you can see the nested if-statements at work:

## View and Duplicate Database

Nested If Statements
College Info Geek on Notion
Other formula components used in this example:

### About the Author

My name is Thomas Frank, and I'm a Notion-certified writer, YouTuber, and template creator. I've been using Notion since 2018 to organize my personal life and to run my business and YouTube channel. In addition to this formula reference, I've created a free Notion course for beginners and several productivity-focused Notion templates. If you'd like to connect, follow me on Twitter.