Search

if() and ifs() | Beginner’s Guide to Notion Formula

post type
notion
formula
tutorial
status
published
author
created time
2024/03/11 11:17
description
This blog post provides a deeper insight into the if and ifs formulas in Notion. TThe post explains how these formulas work and provides examples.
cover image
Frame 14.png
1 more property

This is your sign to try out if() and ifs()

The if and ifs functions are among the most useful and versatile formulas in Notion. This tutorial will explain what these functions do, how to use them, and provide some practical examples. Let's get started!
For this guide, I referenced the Notion Formula documentation and added my own examples and explanations.

Summary

Name
Syntax
How it works
Example
if
if(condition, ifTrue, ifFalse)
Returns the first value if the condition is true; otherwise, returns the second value.
if(true, 1, 2) → 1 if(false, 1, 2) →  2 
ifs
ifs(condition, ifTrue, condition2, ifTrue2, ..., else)
Returns the value that corresponds to the first true condition. This can be used as an alternative to multiple nested if() statements.
ifs(true, 1, true, 2, 3) → 1 ifs(false, 1, false, 2, 3) → 3

if() Formula

How if() works

The if() function is used to return values based on whether the multiple conditions are true or false.
Here's how you would write the if statement in Notion:
if(condition, ifTrue, ifFalse)
Notion Formula
복사
Breaking it down
condition: The condition is a special kind of statement that must be either true or false.
ifTrue: The value to return if the condition is true.
ifFalse: The value to return if the condition is false.

Example of if

Search
example
description
formula
results
Returns the value in ifFalse as the condition is set to true.
if(false, 1, 2)
2
Uses a checkbox property as a condition and returns values based on its state.
if(prop("Task Complete"), "Complete", "Incomplete") - Suppose there is a checkbox property called “Task Complete.” If it is checked (true), it will return “Complete”; if it is not checked, it will return “Incomplete.” - Here, assume that the Task Complete property is marked checked.
Complete
Uses the .empty() function on a property as a condition and returns values depending on whether the property is empty or not.
if(prop("Date").empty(), "Date is empty", "Date is not empty") - Suppose there is a date property called “Date.” If it is empty (true), it will return “date is empty”; if it is not checked, it will return “date is not empty”. - Here, assume that the Date property is not empty.
Date is not empty.

ifs Formula

How ifs works

The ifs function is used to return different values based on whether multiple conditions are true or false.
Here's how you would write the ifs statement in Notion:
ifs(condition, ifTrue, condition2, ifTrue2, ..., else)
Notion Formula
복사
# Before with if() if(condition1, ifTrue, if( condition2, ifTrue2, ifFalse2 ) )
Notion Formula
복사
# After with ifs() ifs( condition1, ifTrue, condition2, ifTrue2, ..., ifFalse )
Notion Formula
복사
Breaking it down
Just as if() is singular and ifs() is plural, you can think of an ifs() statement as an if() statement with multiple conditions. Each condition can yield a different value, depending on whether it's true or false. It's a convenient alternative to using multiple nested if() statements.
condition1, 2,…: The condition is a special kind of statement that must be either true or false.
Note that if both condition 1 and condition 2 are true, the value of the preceding condition that appears first will be returned.
ifTrue1, ifTrue2,…: The value to return if the corresponding condition (e.g., condition 1, ifTrue 1) is true.
ifFalse: The value to return if all conditions is false.

Example of ifs

Search
example
description
formula
results
condition 1 and condition 2 are true - If both condition 1 and condition 2 are true, the value of the preceding condition that appears first will be returned.
ifs(true, 1, true, 2, 3)
1
condition 1 and condition 2 are false - If both conditions are false, the value associated with ifFalse will be returned.
ifs(false, 1, false, 2, 3)
2
The condition uses the .equal(…) to check if it meets the specified condition.
ifs( prop("Priority").equal("High"), "", prop("Priority").equal("Medium"), "", "") - Here, let’s say the property Priority is set to High. - In this example, if Priority, the Status property, equals "High", it will return "". If the "Priority" equals "Medium", it will return "". If neither conditions are met, it will return "".

Conclusion

Thank you for reading this tutorial! If you found it helpful, be sure to check out shop for my beautiful templates, which I am confident enough to say are a game-changer Subscribe to my newsletter and feel free to follow me on my social media for updates!
Happy Notion(ing)!
Search