How to write basic database formulas on Notion
Writing database formulas in Notion involves adding a Formula property to your database and using Notion's formula syntax to perform calculations. You can combine text, numbers, and other properties using functions like add, multiply, concat, and if statements.
Prerequisites
- Basic familiarity with Notion interface
- Understanding of database properties
- Knowledge of basic mathematical operations
- Created at least one database in Notion
Step-by-Step Instructions
Add a Formula Property to Your Database
Open the Formula Editor
Write a Basic Mathematical Formula
prop("Quantity") * prop("Price"). Use prop("Property Name") to reference other columns in your database. You can use operators like +, -, *, / for basic math.Use Text Functions for String Operations
concat() function: concat(prop("First Name"), " ", prop("Last Name")). For text manipulation, try functions like upper() to convert to uppercase, lower() for lowercase, or length() to count characters.Create Conditional Logic with IF Statements
if() functions to create conditional formulas: if(prop("Status") == "Complete", "✅ Done", "⏳ In Progress"). The syntax is if(condition, value_if_true, value_if_false). You can nest multiple if statements for complex logic.Work with Dates and Times
dateBetween() to find differences: dateBetween(prop("Due Date"), now(), "days"). Use now() for current date/time, dateAdd() to add time periods, and formatDate() to customize date display.Test and Refine Your Formula
Common Issues & Troubleshooting
Formula shows 'Type mismatch' error
Check that you're using the correct data types. Make sure number properties contain actual numbers, not text. Use toNumber() function to convert text to numbers if needed.
Property reference not working
Verify that the property name in your prop() function exactly matches the column name, including capitalization and spaces. Property names are case-sensitive in formulas.
Formula returns empty or null values
Use the empty() function to check for null values and provide defaults: if(empty(prop("Price")), 0, prop("Price")). This prevents calculations from breaking when cells are empty.
Complex formula is difficult to read
Break complex formulas into multiple formula properties, or use line breaks and proper spacing in the formula editor to make your code more readable. Consider using intermediate calculations in separate columns.