Search

if and ifs | Deeper Insight into Notion Formula

post type
notion
formula
status
published
author
created time
2024/03/11 11:17
3 more properties
Hey guys, welcome to my blog :)
The if and ifs functions are among the most useful and versatile formulas in Notion. They allow you to customize your database and manipulate its properties, helping to automate your workspace and make data management tasks more efficient. 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.
code index code Database Database property Name of the property Database view Menu Options
table of content

Summary

Name
Description
How it works
Example
if
Returns the first value if the condition is true; otherwise, returns the second value.
if(condition, value if condition is true, value if condition is false)
if(true, 1, 2) = 1 if(false, 1, 2) = 2  prop("Checked") == true ? "Complete" : "Incomplete"
ifs
Returns the value that corresponds to the first true condition. This can be used as an alternative to multiple nested if() statements.
ifs(condition_1, value if condition_1 is true, condition_2, value if condition_2 is true, ... condition_n, value if condition_n is true, ... value if ALL condition is false )
ifs(true, 1, true, 2, 3) = 1 ifs(false, 1, false, 2, 3) = 3

if Formula

The if formula is used to return different values based on whether a specific condition is true or false.

How if works

Here's how you would write the if statement in Notion: if(condition, value if true, value if false)
In the if statement, the "condition" is a special kind of statement that must be either true or false. These true or false statements are known as Boolean values in coding. If you're new to coding, you can think of Boolean values as a way to represent something that is either on or off, yes or no, true or false, and so on.
In Notion, you can create Boolean values in several ways. One of the most common ways is by using a checkbox. If the checkbox is checked, that's considered true. If it's unchecked, that's false. You can also create Boolean values by comparing two things using equals (==) or equal().
One important thing to note about the if statement is that the "value if true" and the "value if false" (the 2nd and 3rd parameters respectively) need to be of the same type. This means that if the "value if true" is a number, the "value if false" should also be a number. Similarly, if the "value if true" is a text, the "value if false" should also be a text.
Remember, the "condition" is a Boolean value (something that is either true or false), and the "value if true" and "value if false" should be of the same type.

Example of if

if(true, 1, 2) -> This will always return 1 if(false, 1, 2) -> This will always return 2
Notion Formula
복사
In the examples above, true and false are the conditions. If the condition is true, the formula will return the first value (1 in this case). If the condition is false, it will return the second value (2 in this case).
Another example can be:
if(prop("Checked"), "Complete", "Incomplete")
Notion Formula
복사
In this case, the formula checks if Checkbox Property(titled Checked) is ticked (true) or unticked (false). If Checked is ticked, it will return "Complete". If the Checked is unticked, it will return "Incomplete".
Last example can be:
if(prop("Progress").equal("Complete"), "Done", "Pending")
Notion Formula
복사
if function to check the value of the ety. If the value of "Progress" equals to "Complete", the formula will return "Done". If the value of "Progress" does not equal "Complete", it will return "Pending". This can be useful for tracking task progress within a Notion database.

ifs Formula

The ifs formula is used to return different values based on whether multiple conditions are true or false.

How ifs works

Here's how you would write the ifs statement in Notion:
ifs(condition_1, value if condition_1 is true, condition_2, value if condition_2 is true, ... condition_n, value if condition_n is true, ... value if ALL condition is false )
Notion Formula
복사
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.
# Before if(condition_1, value if condition_1 is true, if(condition_2, value if condition_2 is true, value if condition_3))
Notion Formula
복사
# After with ifs if(condition_1, value if condition_1 is true, condition_2, value if condition_2 is true, value if condition_3)
Notion Formula
복사
In the ifs statement, there are multiple "conditions" which are special kind of statements that must be either true or false. These true or false statements are known as Boolean values in coding. If you're new to coding, you can think of Boolean values as a way to represent something that is either on or off, yes or no, true or false, and so on.
Similar to the if statement, the condition is a boolean that determines which value or statement will be displayed in the database. Note that all "value if condition_n is true" must be of the same type.

Example of ifs

ifs(true, 1, true, 2, 3) -> This will return 1 ifs(false, 1, false, 2, 3) -> This will return 3
Notion Formula
복사
In the first example, the formula checks each condition in order. The first true condition it encounters is the very first one (true), so it returns the corresponding value (1). In the second example, all the conditions are false except for the last one, so it returns the last value (3).
ifs(prop("Priority").equal("High"), "Urgent", prop("Priority").equal("Medium"), "Important", "Normal")
Notion Formula
복사
In this example, if Priority, the Status property, equals "High", it will return "Urgent". If the "Priority" equals "Medium", it will return "Important". If neither conditions are met, it will return "Normal".
ifs(prop("Age") < 12, "Child", 12 < prop("Age") and prop("Age") < 19, "Teenager", "Adult")
Notion Formula
복사
In this example. if Age, the Number property is less than 12, it displays a message “Child. If Age is inbetween greater than 12 and less than 19, it displays “Teenager”. If neither of these conditions are met, the only possibility is Age being greater or equal to 19, so it will return “Adult”

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)!