Formulas and Databases

Reference

Formula Examples

Notion Formula Syntax

Learn the basics of Notion's formula syntax.

Notion formulas are not written in any previously established programming or scripting language.

They're written in "Notion Formula Syntax" βΒ however, you'll find that syntax is *very *similar to the syntax used within Microsoft Excel/Google Sheets formulas.

You'll likely also see some similarities to Javascript syntax, though Notion Formula Syntax is far simpler.

Refer to my guide on writing complex formulas to see how you can remove these elements before pasting your formulas from a text editor into Notion's editor.

In Notion formulas, parentheses

`()`

are used to open and close functions:1

abs(-20) // Output: 20

Commas

`,`

are used to separate arguments in functions:1

add(34,8) // Output: 42

Quotation marks

`"`

are used to:- 1.
- 2.Reference property names within the
`prop()`

function

1

// Assume the value of the Name property is "Luffy"

2

concat("Monkey D. ", prop("Name")) // Output: Monkey D. Luffy

As in most programming languages, the plus sign

`+`

can be used for both numeric addition and string concatenation:1

38 + 4 // Output: 42

2

β

3

"Monkey" + "D. " + "Luffy" // Output: Monkey D. Luffy

There are several other operators, which perform calculations on one or more **operands. **

Most operators are **binary operators, **which means they work on two operands:

1

10 / 2 // Output: 5

2

β

3

(4 + 5) == 9 // Output: true

4

β

5

9 < 8 // Output: false

1

-(-10) // Output: 10

2

β

3

+"42" // Output: 42 (string converted to a number)

The **ternary operator **(

`?`

and `:`

) operates on three operands, and can be substituted for the if function:1

42 > 25 ? "Yes" : "No" // Output: Yes

2

β

3

if( 42 > 25, "Yes", "No") // Output: Yes

When performing mathematical operations, operators follow standard mathematical order of operations.

Refer to the operator precedence guide (which also defines precedence for Boolean operators) for more detail, and remember that you can always use parentheses

`()`

to specify the order you want:1

4 + 8 / 4 - 2^2 // Output: 2

2

4 + (8 / 4) - (2^2) // Output: 2

3

β

4

(4 + 8) / (4 - 2) ^ 2 // Output: 3

5

π // simplified

6

(12) / (4) // Output: 3

Notion's formula editor includes many functions, which are reusable blocks of code that you can call.

Functions accept one or more **arguments, **operate on the data of those arguments using internal logic, and output a result.

1

// function_name(argument_1, argument_2)

2

β

3

divide(10,2) // Output: 5

4

β

5

// Note that spaces between arguments are optional, but

6

// commas are required.

7

concat("My", " ", "Chemical", " ","Romance")

8

// Output: My Chemical Romance

Functions can accept other functions as arguments. The inner-most functions are executed first, and their **output **is used as the argument value for the function that contains them.

1

/* Example 1 */

2

// Compressed

3

divide(add(8,2), subtract(5,3)) // Output: 5

4

β

5

// Expanded

6

divide(

7

add(8,2),

8

subtract(5,3)

9

)

10

β

11

---

12

β

13

/* Example 2 */

14

// Compressed

15

if(equal(add(8,4),multiply(3,4)),concat(format(add(8,4))," and ",format(multiply(3,4))," are equal!"),concat(format(add(8,4))," and ",format(multiply(3,4))," are not equal!"))

16

β

17

// Expanded

18

if(

19

equal(

20

add(8,4),

21

multiply(3,4)

22

),

23

concat(

24

format(

25

add(8,4)

26

),

27

" and ",

28

format(

29

multiply(3,4)

30

),

31

" are equal!"

32

),

33

concat(

34

format(

35

add(8,4)

36

),

37

" and ",

38

format(

39

multiply(3,4)

40

),

41

" are not equal!"

42

)

43

)

Notion formulas also do **not **support:

- Loops (for, while, etc.)
- Recursion
- Arrays
- Objects
- Custom, reusable functions

You will not find yourself using curly braces

`{}`

or brackets `[]`

in Notion formulas.Additionally, you'll learn to start thinking bigger than a single formula. Many complex tasks will require multiple formula properties, "helper" properties that store variables, etc.

β My name is Thomas Frank, and I'm a Notion-certified writer, YouTuber, and template creator. I've been using Notion since 2018 to organize my personal life and to run my business and YouTube channel. In addition to this formula reference, I've created a free Notion course for beginners and several productivity-focused Notion templates. If you'd like to connect, follow me on Twitter.

Last modified 1mo ago

Copy link