Text and numbers mixed
How you'll know: The editor flags a type error on a comparison or a plus sign.
Fix: Turn text into a number with toNumber(), or a number into text with format(), before you combine them.
You want a column that says how many days are left, or flags a task as overdue, and the editor keeps answering with a red error. A Notion formula is a property that calculates its value from the other properties on the same page, and through relations, from related pages too. The current syntax, Formulas 2.0, reads like a small programming language: properties, functions, and lists you can filter and add up.
Add one: in the database, add a property, choose Formula, then Edit formula.
Slider icon › Edit properties › New property › FormulaPoint at a property: type prop("Due Date"). The editor shows it as a token with the property's name.
Reach related pages: use a dot, as in prop("Tasks").length(). Inside map() or filter(), current means each item in turn.
Check the output: turn on Show types in the editor to see whether you're getting text, a number, a date or a list.
dateBetween(prop("Due"), today(), "days") The later date goes first. Once the task is overdue the number turns negative.if(and(now() > prop("Due"), prop("Status") != "Done"), style("Overdue", "red", "b"), "") "Done" has to match your status option's name exactly.ifs(prop("Score") >= 80, "High", prop("Score") >= 50, "Medium", "Low") Score must be a number property. If it's text, wrap it: toNumber(prop("Score")).prop("Tasks").map(current.prop("Hours")).sum() Tasks has to be a relation. You don't need a rollup for this any more.prop("Tasks").filter(current.prop("Status") == "Done").length() Pair it with the total from prop("Tasks").length() for a progress figure.lets(rate, prop("Rate"), hours, prop("Hours"), rate * hours) Correct math, but only as fresh as whoever last typed the rate.formatDate(prop("Due"), "MM/DD/YYYY") The result is text, so you can't sort or filter it as a date.Use a rollup when a plain total does the job. Use a formula when you need "only the open ones" or "only this quarter" before the math.
How you'll know: The editor flags a type error on a comparison or a plus sign.
Fix: Turn text into a number with toNumber(), or a number into text with format(), before you combine them.
How you'll know: Most rows calculate and a few stay blank.
Fix: Rows with no date or number have nothing to work with. Guard for it: if(empty(prop("Due")), "", dateBetween(prop("Due"), today(), "days")).
How you'll know: The overdue flag stopped showing after someone renamed Done to Complete.
Fix: Text inside quotes doesn't follow a rename. Update the string in the formula to the new option name.
How you'll know: You pasted it exactly and it still won't save.
Fix: Examples written before Formulas 2.0 may not paste in cleanly, and many rely on a rollup step you no longer need. Rebuild it with prop(), dot notation and list functions.
A formula can only read the page it sits on and pages linked to it. Today's exchange rate, a client's open balance in the billing system, or the hours from your time tracker aren't in Notion, so someone types them into a property and the formula calculates from whatever was typed last. The math is right and the answer is stale.
n-frames fills those properties from the source through the Notion API, on a schedule or when the number changes in the other system, so the formula works from today's figure. When a calculated status should start something outside Notion, a follow-up, an invoice, a message to a client, that step can read the same property. Our Notion databases page covers the relations and views most formulas sit on.
A database property whose value is calculated rather than typed. It reads the other properties on the same page, and related pages through relations, and can do date math, conditions, text and list work. You can't edit its value by hand.
No. A formula only sees properties in its own database and in related pages. A number from another system has to land in a property first, typed by someone or written by an integration through the Notion API.
Use dateBetween() with two dates and a unit: years, quarters, months, weeks, days, hours or minutes. It subtracts the second date from the first, so dateBetween(prop("End"), prop("Start"), "days") gives a positive number when End is later.
Yes. Formulas 2.0 added lists, dot notation through relations, let() and lets() for named values, and style() for colored text. Formulas written in the older syntax generally keep working, but examples from old tutorials may need rewriting.
On Business and Enterprise plans, yes. It can help write a formula from a plain description, though Notion says it can't handle loop-style logic, and there's no random() function for it to reach for.