No Idea How to Use Notion Formula? Start here
In a Notion database, properties add various types of context to your items or pages, such as due dates, task owners, URLs, and timestamps. Each property holds specific information relevant to the database item. One of the most powerful property types in Notion is the Formula property.
What does Formula Do?
Formulas allow you to manipulate data dynamically, transforming simple property values into insights and helping to organize and prioritize your information effectively.
1.
Derive Values from Other Properties & Make a “Different Meaing” Out of Them: 99% of the time, we use Formula based on properties values added to the database items. Formulas can take the values from other properties in the database and process them further to create meaningful outputs. For instance, you can use a formula to calculate the number of days remaining until a due date, or to display specific text based on conditions.
2.
Perform Conditional and Mathematical Operations: Formulas support complex logic like conditional statements (if, and, or), which enable you to perform actions based on property values. Additionally, formulas allow for mathematical operations to be performed on numeric properties—such as totals, averages, and other calculations.
3.
Create Independent Outputs: Although formulas most of the time rely on existing property values, they can also generate outputs independently of other database properties. For example, a formula like 2 + 5 will return 7, which will display consistently across all database items.
How Does Formula Work?
As mentioned in step 2 of the previous paragraph, you can do logical and arithmetic calculations using operators like +, -, and, or, and others. However, more often than not, we utilize functions to work with properties, so let’s explore that in greater detail.
In Notion, the formula syntax lets you perform various computations by combining functions (predefined actions) and inputs (values to manipulate). When you set up a formula in a Notion database, the output (result) of that formula will be calculated and displayed in each row’s formula property.
A visual analogy for how input, function, and output work together
About ‘input’
In Notion, the input is typically the value of a property added to a database item. Formulas support nearly all property types, allowing flexibility with inputs.
You can select a property of a database item by clicking on it in the formula editor under the menu bar or by typing prop("Property Name"). This lets you reference any property directly in your formula.
Check out properties supported by Notion & Notion data type for properties or data that could be used as an input in Notion Formula.
About ‘function’
In Notion, a function is predefined. A function that performs specific tasks using parameters you provide. The structure usually follows this format:
exampleFunction(parameter1, parameter2, parameter3, ...)
Notion Formula
복사
Each parameter represents an input that the function needs to operate. Parameters can be:
•
Properties: Specific data fields from your Notion database, referenced using prop("Property Name").
•
Values/Literals: Fixed values, like numbers or text, directly provided in the formula (e.g., 3, "days").
Explore the Notion data types to see the various types of parameters supported by Notion.
About ‘output’
In Notion, the output refers to what is returned after a function is applied.
Check out the Notion data types to discover the different types of outputs supported by Notion.
Properties supported by Notion Formula
Here are lists of properties supported by Notion Formula.
Property Types | Examples | Formula Type |
Title | prop("Title")
prop("Title").length() | Text |
Text | prop("Text")
prop("Text").length() | Text |
Select | prop("Priority") == "High" | Text |
Multi-Select | prop("Tags").length()
prop("Tags").includes("Finance") | Text (list) |
Checkbox | prop("Checkbox")not prop("Checkbox") | Boolean |
Email, URL, Phone Number | !empty(prop("Phone"))!empty(prop("Email"))link("Call", "tel:" + prop("Phone")) | Text |
Unique ID | prop("Task ID").split("-").first() ← Prefix
prop("Task ID").split("-").last() ← ID | Text |
Created By,Edited By | prop("Created By").name()prop("Created By").email() | Person |
Person | prop("Person")prop("Person").at(0).name()prop("Person").map(current.email()) | Person (list) |
Date,Created Time,Last Edited Time | prop("Due Date") > now()dateBetween(prop("Birthday"), now(), "days") | Date |
Number | prop("Number") / 2pi() * prop("Radius") ^ 2 | Number |
Relation | prop("Tasks").length()prop("Tasks").filter(current.prop("Status") !== "Done") | Page (list) |
Rollup | prop("Purchases").length()prop("Average cost") * 12 | Number, date, or list of any type. Depends on rollup configuration. |
Notion Data Types
Here are data or values supported by Notion Formula.
Data type | Description | Example |
Text | Text value | “Hello World” |
Number | Numeric value. It can be also displayed using the formatting options of the Formula property (e.g., as a percentage, currency, or with a ring or bar). | 1, -2.5 |
Date | Displays as a date with time. | (e.g., August 29, 2023, 1:33 PM) |
People | You can use name() or email() to retrieve data from any People type. Displays as people’s names with their photos. | |
Booleans | Can be true or false. Displays as a filled or unfilled checkbox. | true, false |
Pages | Represents Notion pages, like relations. You can retrieve the properties of a given Notion page by using | Multi-select, People, Relation, and most Rollup properties will return list values. |
Lists (or Arrays) | Lists can hold items of any type, including more lists. Multi-select, People, Relation, and most Rollup properties will return list values. | |
Empty | The empty value is not displayed in the output of a formula property but can be used in computations. | “” or [] |
Example of Using Formula
Let’s Say you have a property called Date in your database and want to subtract 14 days from it. This can be done by Notion’s Formula!
In the Formula editor, when you type dateSubtract(), it will display guidance on how to use the function along with a breakdown of its components. Here’s what you can learn:
•
dateSubtract(...): This function is designed to subtract a specified amount of time from a date. It takes three parameters:
◦
date: the date you want to modify.
◦
number: the quantity of time to subtract.
◦
unit: a predefined value that can be one of the following: “years,” “quarters,” “months,” “weeks,” “days,” “hours,” or “minutes.”
So in our case, the first paramter is the date property, 2nd is 14, since we want to get the date 14 days ago, and third is days since we are looking for differences between days: hence
Here are more Formulas that you can take as an inspiration!
Additional Information
1.
More complex operations can also be accomplished by combining multiple functions.
For instance, consider a cookie as the output of one function. You can then use this cookie as input for another function that takes in a cookie and returns a s’more chocolate chip cookie. This can be done by simply nesting or chaining the functions together! We’ll explore this concept in greater detail in the next article.
2.
When you type a function name in the Formula editor, Notion provides a quick description of what the function does and the parameters it requires.
3.
Notion also offers an alternative syntax for certain functions. Instead of using function(parameter1, parameter2), you can write it as parameter1.function(parameter2). This syntax can enhance the readability of formulas and reduce errors by visually associating the main property with its corresponding function.
From:
dateSubtract(prop("Date"), 14, "days")
Notion Formula
복사
To this:
prop("Date").dateSubtract(14, "days")
Notion Formula
복사
Conclusion
Notion formulas are a vital feature for users aiming to maximize the potential of their databases. I hope you enjoy this article and continue your journey in exploring the capabilities of formulas! 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)!
links
Search