Skip to content

Language basics

A formula is an ordered list of statements. Each statement receives the current row array and returns the next one: the first statement reads the rows that arrive, and the rows the last statement returns are what the step writes onward. Inside a statement, expressions compute values with Notion Formula 2.0 syntax.

input rows
→ statement 1 → rows₁
→ statement 2 → rows₂
→ … → rows written onward

Statements run top to bottom. Within one statement, rows are processed in the order they arrive, and rowIndex() is the current row’s zero-based position.

A statement changes the rows: it sets a field, drops a row, sorts, groups, or raises an exception. An expression computes a value: prop("price") * 1.2, upper(prop("side")), today().

setProp("price_with_vat", prop("price") * 1.2)

Here setProp is the statement and prop("price") * 1.2 the expression. A bare expression in statement position, such as prop("price") + 1 on its own line, is a type error: values are written with setProp.

Kind Examples Page
Row statements setProp, unsetProp, keepProps, dropRow, filter, sortBy, groupBy, insertRow, splitRows, appendRows, spreadProps, each Statements
Control statements if(condition, statement), if(condition, statement, statement), do(statement, …) Statements
Checks raiseException() and its chained .setProp Validate data
Styles setStyle, setRowStyle, clearStyle, clearRowStyle Styles and view formulas
Verbs and shaping statements fromFile, toFile, fromApi, fromAi, setType, rowKey, subgrid, … Load data, Export data
Expressions Logic, text, numbers, dates, lists Function reference

if works both ways. With statements as branches it is a statement; with values as branches it is the Notion value form:

# Statement form: runs setProp only where the condition is true
if(prop("side") == "buy", setProp("sign", 1), setProp("sign", -1))
# Value form: one setProp, with if choosing the value
setProp("sign", if(prop("side") == "buy", 1, -1))

Both branches of one if are statements, or both are values.

  • Line breaks: a statement ends at a line break where parentheses and brackets are balanced. A line that starts with . continues the previous statement, which is how you chain .setProp(…) and .setStyle(…) across lines.
  • Blank lines and comments: blank lines are ignored. Comments are /* … */, or # to the end of the line. A line that holds only a comment counts as blank.
  • Strings: double quotes, with \" and \\ as escapes.
  • Raw text: text between backticks spans lines and keeps every character as written, with no escapes. Use it for a query, a template, or an AI prompt. Raw text cannot contain a backtick.
  • Numbers: a number may group its digits with _: 130_000_000 is 130000000.
  • Names: function names are case-sensitive: setProp, groupBy, dropRow.
  • Column names: prop("Exact column name") reads a column by its exact name. An unknown name is a type error (Cannot find property "Name"). getProp(name) is the same function.
  • Literal names: the name argument of setProp, unsetProp, keepProps, splitRows, context().setProp, and spreadProps().prefix(text) is a text literal, not a computed value.
# Chain across lines with a leading dot
raiseException("price")
.setProp("message", "Price is missing")
.setProp("severityLevel", 3)

Every function can be called two ways. upper(prop("name")) and prop("name").upper() are the same: in the dot form, the receiver is the first argument.

setProp("code", prop("isin").substring(0, 2).upper())
setProp("code", upper(substring(prop("isin"), 0, 2)))

List functions that take a condition or an expression (map, filter, find, findIndex, some, every) bind current to the item and index to its zero-based position inside that argument:

setProp("doubled", [1, 2, 3].map(current * 2)) # [2, 4, 6]
setProp("has_large", prop("amounts").some(current > 1000))

A function that is not in the function reference does not exist, and calling it is an unknown-function error (Cannot find function len()).

Type Holds Written as
text A string "EUR", or raw text between backticks
number An exact decimal 42, 0.125, 130_000_000
boolean true or false true, false
date A UTC date and time parseDate("2026-09-30"), now(), today()
list<T> A list of values [1, 2, 3]
object A JSON object inside a cell read with .prop("field")
empty An absent value an empty cell, "", or a lookup that found nothing

A column takes its type from the schema of the rows that arrive: JSON string is text (or date when its format is date or date-time), number and integer are number, array is a list, object is an object. A column whose type is unknown is any.

The type of a column threads through the statements. prop("price") is a number before groupBy, a list of numbers after it, and a number again after setProp("price", prop("price").sum()). A column has one type at any point, so a setProp that writes a different type into an existing column is a type error. To change a column’s type on purpose, use setType; see Map and shape columns.

Every number is an exact decimal while a formula computes: literals, column reads, arithmetic, and list reducers. 5 / 10 is 0.5 and 0.1 + 0.2 is 0.3. A number written to a cell is stored by the column’s schema type: an integer column truncates, and a numeric column that setProp creates is a decimal number.

Dates are UTC and are written to cells as ISO-8601 text. now() and today() read one fixed clock per run, so every row of a run sees the same time. Date units are "years", "quarters", "months", "weeks", "days", "hours", and "minutes". See Transform values.

empty(value) is true for an empty cell, "", 0, and []. There is one blank text value: an empty text cell and "" are equal, fall into one groupBy group, and match each other in find, includes, and unique.

A blank number is not 0. Arithmetic on an empty number fails the run with “Numeric operand is empty”, so test it first:

setProp("total", if(empty(prop("fee")), prop("amount"), prop("amount") + prop("fee")))

Tightest first:

Operators Meaning
f(…), .f(…) Calls and dot calls
not, !, unary - Negation
^ Power, right-associative: 2 ^ 2 ^ 3 is 256
*, /, % Multiply, divide, remainder
+, - Add and subtract; + also joins two texts
==, !=, !==, >, >=, <, <= Comparison
and, && Logical and
or, || Logical or
X ? Y : Z Same as if(X, Y, Z)
  • + adds two numbers or joins two texts. To join a text and a number, convert the number: "Qty " + format(prop("qty")).
  • == is strict: "1" == 1 is false. Two lists are equal only when their items are equal in order, so [1, 2] == [2, 1] is false.
  • <, <=, >, and >= compare numbers, texts, dates, or booleans (false < true).
  • and(a, b), or(a, b), and not(a) are also calls.

let(name, value, body) binds a name for the body, so you compute a value once and use it twice. lets(name, value, name2, value2, …, body) binds several.

setProp("band", lets(
q, prop("qty"),
p, prop("price"),
if(q * p > 1_000_000, "large", "standard")
))

A binding lives inside its expression only, so it never carries over to the next statement. Write a value to a column, or to context(), to use it later.

context() is one object for the whole formula run. It starts empty. A value you write on one row is visible to later rows and to later statements, which makes running totals and maximums possible without grouping.

context().setProp("running", 0)
do(
context().setProp("running", context().prop("running") + prop("amount")),
setProp("running_total", context().prop("running"))
)
  • A statement runs over every row before the next statement starts. The running total therefore adds and writes in one do(…): split into two statements, the second would see the final total on every row.
  • A constant write such as context().setProp("running", 0) runs on every row and leaves that constant.
  • Write a context key before you read it: reading a key no statement has written yet is a type error.
  • A key’s type is the type of its first context().setProp.
  • Context stays inside the formula and is not passed to the next node.

Verbs can also write a context value: context("body").fromTemplate(…) keeps a rendered text as one value while the rows pass through. Read it with context().prop("body").

A cell whose type is an object holds structured JSON, such as a trade leg or an issuer record. .prop reads its fields, and you can chain it into nested fields:

setProp("country", prop("leg").prop("issuer").prop("country"))
  • A field the schema names keeps its type, so the editor reports a name the schema does not have. When the schema names no fields, any name is allowed and a missing field reads empty.
  • A list of objects works with the list functions: prop("legs").filter(current.prop("side") == "BUY") is the buy legs, and prop("legs").map(current.prop("notional")).sum() their total notional.
  • A cell holds text, a number, a boolean, a date, or a list of those, so setProp cannot write an object. A cell no statement writes keeps the JSON it arrived with, so reading an object never rewrites it.

To turn a list of objects into rows, see Map and shape columns.

A column cannot be written under a name that is a built-in member of JavaScript objects, such as constructor, toString, valueOf, or __proto__: setProp reports Column name "constructor" is reserved. Reading such a column is allowed.

The grammar below is generated from the parser. Quoted strings are literal tokens.

program ::= ( statement ( newline statement )* )?
statement ::= label | expression
label ::= "ffl" identifier
expression ::= orExpression ( "?" expression ":" expression )?
orExpression ::= andExpression ( ( "or" | "||" ) andExpression )*
andExpression ::= comparison ( ( "and" | "&&" ) comparison )*
comparison ::= additive ( ( "==" | "!=" | "!==" | ">" | ">=" | "<" | "<=" ) additive )*
additive ::= multiplicative ( ( "+" | "-" ) multiplicative )*
multiplicative ::= power ( ( "*" | "/" | "%" ) power )*
power ::= unary ( "^" power )?
unary ::= "not" unary | "!" unary | "-" unary | postfix
postfix ::= primary dotCall*
dotCall ::= "." functionName argumentList
functionName ::= identifier | "and" | "or" | "not" | "ffl"
argumentList ::= "(" ( expression ( "," expression )* )? ")"
primary ::= text | rawText | number | "true" | "false" | list | "(" expression ")" | identifier argumentList? | ( "and" | "or" | "not" | "ffl" ) argumentList
list ::= "[" ( expression ( "," expression )* )? "]"

A newline ends a statement only where parentheses and brackets are balanced and the next non-blank line does not start with .; every other newline is whitespace. Parentheses, brackets, and the expression tree nest at most 100 levels deep.