哈囉!感謝你拜訪我們的幫助中心。目前我們的幫助中心還在建設中。我們將在不久的將來呈現幫助中心的內容。感謝你的理解,我們未來再見!

Formula syntax & functions

Formulas functions hero
在本文內

Notion formulas can operate on various properties and functions. Here, you'll find a list of them ➗


  • Looking for Notion formula basics? Check out this article →

  • If you have a formula that doesn't seem to work, learn about common formula errors and how to troubleshoot them in this article →

Know what you want your formula to do, but not sure how to build it? You can use Notion AI to create and edit formulas. Learn more here →

Notion formulas can operate using various properties and functions. Here, you'll find a list of them!

Formulas support almost all property types. Note that formula types are different from property types.

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") / 2
pi() * 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.

Built-ins are specific symbols and values that are built into the language to help designate a calculation.

Built-in

Example

Math operators:
+, -, *, %

2 * pi()
"hello" + "world"

Boolean values:
true, false

true
false

Comparison operators:
==, >, >=, <, <=

123 == 123 = true
"Notion" == "Motion" = false

Logical operators:
and, or, not

and:
true and false
true && false

and(true, false)
or:
true or false
true || false

or(true, false)
not:
not true
!true

Ternary operator:
? :

X ? Y : Z is equivalent to if(X, Y, Z)

Notion formulas support the following functions.

Name

Description

Example

if

Returns the first value if the condition is true; otherwise, returns the second value.

if(true, 1, 2) = 1
if(false, 1, 2) = 2 prop("Checked") == true ? "Complete" : "Incomplete"

ifs

Returns the value that corresponds to the first true condition. This can be used as an alternative to multiple nested if() statements.

ifs(true, 1, true, 2, 3) = 1
ifs(false, 1, false, 2, 3) = 3

empty

Returns true if the value is empty. 0, “”, and [] are considered empty.

empty(0) = true
empty([]) = true

length

Returns the length of the text or list value.

length("hello") = 5
length([1, 2, 3]) = 3

substring

Returns the substring of the text from the start index (inclusive) to the end index (optional and exclusive).

substring("Notion", 0, 3) = "Not"
substring("Notion", 3) = "ion"

contains

Returns true if the search string is present in the value.

contains("Notion", "ot") = true

test

Returns true if the value matches the regular expression and false otherwise.

test("Notion", "Not") = true
test("Notion", "\\d") = false

match

Returns all matches of the regular expression as a list.

match("Notion Notion", "Not") = ["Not", "Not"]
match("Notion 123 Notion 456", "\\d+") = ["123", "456"]

replace

Replaces the first match of the regular expression with the replacement value.

replace("Notion Notion", "N", "M") = "Motion Notion"

replaceAll

Replaces all matches of the regular expression with the replacement value.

replaceAll("Notion Notion", "N", "M") = "Motion Motion"
replaceAll("Notion 123", "\\d", "") = "Notion"

lower

Converts the text to lowercase.

lower("NOTION") = "notion"

upper

Converts the text to uppercase.

upper("notion") = "NOTION"

repeat

Repeats the text a given number of times.

repeat("0", 4) = "0000"
repeat("~=", 10) = "~=~=~=~=~=~=~=~=~=~="

link

Creates a hyperlink from the label text and the URL.

link("Notion", "https://notion.so") = "Notion"

style

Adds styles and colors to the text. Valid formatting styles: "b" (bold), "u" (underline), "i" (italics), "c" (code), or "s" (strikethrough). Valid colors: "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", and "red". Add "_background" to colors to set background colors.

style("Notion", "b", "u") = "Notion"
style("Notion", "blue", "gray_background")

unstyle

Removes formatting styles from the text. If no styles are specified, all styles are removed.

unstyle("Text")
unstyle("Text", "b")

format

Returns the value formatted as text.

format(1234) = "1234"
format(now()) = "August 30, 2023 17:55"

add

Returns the sum of two numbers.

add(5, 10) = 15
5 + 10 = 15

subtract

Returns the difference of two numbers.

subtract(5, 10) = -5
5 - 10 = -5

multiply

Returns the product of two numbers.

multiply(5, 10) = 50
5 * 10 = 50

mod

Returns the first number modulo the second number.

mod(5, 10) = 5
5 % 10 = 5

pow

Returns the result of a base number raised to an exponent power.

pow(5, 10) = 9765625
5 ^ 10 = 9765625

divide

Returns the quotient of two numbers.

divide(5, 10) = 0.5
5 / 10 = 0.5

min

Returns the smallest number of the arguments.

min(1, 2, 3) = 1
min([1, 2, 3]) = 1

max

Returns the largest number of the arguments.

max(1, 2, 3) = 3
max([1, 2, 3]) = 3

sum

Returns the sum of its arguments.

sum(1, 2, 3) = 6
sum([1, 2, 3], 4, 5) = 15

median

Returns the middle value of its arguments.

median(1, 2, 4) = 2
median([1, 2, 3], 4) = 2.5

mean

Returns the arithmetic average of its arguments.

mean(1, 2, 3) = 2
mean([1, 2, 3], 4, 5) = 3

abs

Returns the absolute value of the number.

abs(10) = 10
abs(-10) = 10

round

Returns the value of a number rounded to the nearest integer. Supports one or two arguments. In the two-argument case, the first represents the value and the second represents the number of decimal places to round to.

round(0.4) = 0
round(-0.6) = -1
round(1.234, 0)
= 1
round(1.234, 2) = 1.23
round(1234, -2) = 1200

ceil

Returns the smallest integer greater than or equal to the number.

ceil(0.4) = 1
ceil(-0.6) = 0

floor

Returns the largest integer less than or equal to the number.

floor(0.4) = 0
floor(-0.6) = -1

sqrt

Returns the positive square root of the number.

sqrt(4) = 2
sqrt(7) = 2.6457513110645907

cbrt

Returns the cube root of the number.

cbrt(9) = 2.080083823051904
cbrt(64) = 4

exp

Returns e^x, where x is the argument, and e is Euler's number (2.718…), the base of the natural logarithm.

exp(1) = 2.718281828459045
exp(-1) = 0.36787944117144233

ln

Returns the natural logarithm of the number.

ln(2.718281828459045) = 1
ln(10) = 2.302585092994046

log10

Returns the base 10 logarithm of the number.

log10(10) = 1
log10(100000) = 5

log2

Returns the base 2 logarithm of the number.

log2(4) = 2