Functions

A function is a set of statements that performs a task or calculates a value. They allow you to manipulate different types of data in Notion, from text and numbers to lists and pages.

Functions Quick Reference

if

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

Accepts
Returns
Syntax
if(condition, ifTrue, ifFalse) condition.if(ifTrue, ifFalse)
Operator

? :

if(
    1 + 1 == 3, 
    "1 plus 1 equals 3!", 
    "1 plus 1 does not equal 3!"
)if(
    /* Check if 1 plus 1 equals 3 */
    1 + 1 == 3,

    /* If it does, display "1 plus 1 equals 3!" */
    "1 plus 1 equals 3!",

    /* Otherwise display "1 plus 1 does not equal 3!" */
    "1 plus 1 does not equal 3!"
)
=
1 plus 1 does not equal 3! "1 plus 1 does not equal 3!"

Learn more about if →


ifs

Returns the value that corresponds to the first true condition.

Accepts
Returns
Syntax
ifs(condition, ifTrue, condition2, ifTrue2, ..., else) condition.ifs(ifTrue, condition2, ifTrue2, ..., else)
ifs(
    1 + 1 == 1, "1 plus 1 equals 1.", 
    1 + 1 == 3, "1 plus 1 equals 3.", 
    "1 plus 1 equals 2."
)ifs(

    /* Check if 1 + 1 equals 1, and if it does display "1 plus 1 equals 1." */
    1 + 1 == 1, "1 plus 1 equals 1.",

    /* Otherwise check if 1 + 1 equals 2, and if it does display "1 plus 1 equals 3." */
    1 + 1 == 2, "1 plus 1 equals 3.",

    /* Otherwise display "1 plus 1 equals 2." */
    "1 plus 1 equals 2."
    
)
=
1 plus 1 equals 2. "1 plus 1 equals 2."

Learn more about ifs →


and

The boolean operator and.

Accepts
Returns
Syntax
and(boolean, boolean, ...) boolean.and(boolean, ...)
Operator

&& · and

and(
    1 + 2 == 3, 
    3 + 4 == 7, 
    5 + 6 == 11
)and(

    /* Check if 1 plus 2 equals 3 */
    1 + 2 == 3,

    /* Then check if 3 plus 4 equals 7 */
    3 + 4 == 7,

    /* Then check if 5 plus 6 equals 11 */
    5 + 6 == 11

    /* If all of the above are true, return a checked box */
)
=
true

Learn more about and →


or

The boolean operator or.

Accepts
Returns
Syntax
or(boolean, boolean, ...) boolean.or(boolean, ...)
Operator

|| · or

or(
    3 > 2, 
    2 < 3
)
=
true

Learn more about or →


not

Returns the opposite of a boolean value.

Accepts
Returns
Syntax
not(boolean) boolean.not()
Operator

! · not

Learn more about not →


empty

Returns true if the value is empty.

Accepts
Returns
Syntax
empty(value) value.empty()

Learn more about empty →


length

Returns the length of the text or list value.

Accepts
Returns
Syntax
length(value) value.length()

Learn more about length →


substring

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

Accepts
Returns
Syntax
substring(text, startIndex, endIndex?) text.substring(startIndex, endIndex?)

Learn more about substring →


contains

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

Accepts
Returns
Syntax
contains(value, search) value.contains(search)

Learn more about contains →


test

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

Accepts
Returns
Syntax
test(text, pattern) text.test(pattern)

Learn more about test →


match

Returns all matches of the regular expression as a list.

Accepts
Returns
Syntax
match(text, pattern) text.match(pattern)

Learn more about match →


replace

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

Accepts
Returns
Syntax
replace(text, pattern, replacement?) text.replace(pattern, replacement?)

Learn more about replace →


replaceAll

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

Accepts
Returns
Syntax
replaceAll(text, pattern, replacement?) text.replaceAll(pattern, replacement?)

Learn more about replaceAll →


lower

Converts the text to lowercase.

Accepts
Returns
Syntax
lower(text) text.lower()

Learn more about lower →


upper

Converts the text to uppercase.

Accepts
Returns
Syntax
upper(text) text.upper()

Learn more about upper →


trim

Removes whitespace from the beginning and end of the text.

Accepts
Returns
Syntax
trim(text) text.trim()

Learn more about trim →


repeat

Repeats the text a given number of times.

Accepts
Returns
Syntax
repeat(text, count) text.repeat(count)

Learn more about repeat →


padStart

Returns the text padded with the provided padding string at the start until the target length is reached.

Accepts
Returns
Syntax
padStart(text, targetLength, padString) text.padStart(targetLength, padString)

Learn more about padStart →


padEnd

Returns the text padded with the provided padding string at the end until the target length is reached.

Accepts
Returns
Syntax
padEnd(text, targetLength, padString) text.padEnd(targetLength, padString)

Learn more about padEnd →


Creates a hyperlink from the label text and the URL.

Accepts
Returns
Syntax
link(text, url) text.link(url)

Learn more about link →


style

Adds styles and colours to text.

Accepts
Returns
Syntax
style(value, styles) value.style(styles)

Learn more about style →


unstyle

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

Accepts
Returns
Syntax
unstyle(value, styles?) value.unstyle(styles?)

Learn more about unstyle →


format

Returns the value formatted as text.

Accepts
Returns
Syntax
format(value) value.format()

Learn more about format →


formatNumber

Returns the number value formatted as text.

Accepts
Returns
Syntax
formatNumber(value, format?, precision?) value.formatNumber(format?, precision?)

Learn more about formatNumber →


add

Returns the sum of two numbers.

Accepts
Returns
Syntax
add(number, number) number.add(number)
Operator

+

Learn more about add →


subtract

Returns the difference of two numbers.

Accepts
Returns
Syntax
subtract(number, number) number.subtract(number)
Operator

-

Learn more about subtract →


multiply

Returns the product of two numbers.

Accepts
Returns
Syntax
multiply(number, number) number.multiply(number)
Operator

*

Learn more about multiply →


mod

Returns the first number modulo the second number.

Accepts
Returns
Syntax
mod(number, number) number.mod(number)
Operator

%

Learn more about mod →


pow

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

Accepts
Returns
Syntax
pow(number, number) number.pow(number)
Operator

^

Learn more about pow →


divide

Returns the quotient of two numbers.

Accepts
Returns
Syntax
divide(number, number) number.divide(number)
Operator

/

Learn more about divide →


min

Returns the smallest number of the arguments.

Accepts
Returns
Syntax
min(list) list.min()

Learn more about min →


max

Returns the largest number of the arguments.

Accepts
Returns
Syntax
max(list) list.max()

Learn more about max →


sum

Returns the sum of its arguments.

Accepts
Returns
Syntax
sum(list) list.sum()

Learn more about sum →


median

Returns the middle value of its arguments.

Accepts
Returns
Syntax
median(list) list.median()

Learn more about median →


mean

Returns the arithmetic average of its arguments.

Accepts
Returns
Syntax
mean(list) list.mean()

Learn more about mean →


abs

Returns the absolute value of the number.

Accepts
Returns
Syntax
abs(number) number.abs()

Learn more about abs →


round

Returns the value of a number rounded to the nearest integer.

Accepts
Returns
Syntax
round(number) number.round()

Learn more about round →


ceil

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

Accepts
Returns
Syntax
ceil(number) number.ceil()

Learn more about ceil →


floor

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

Accepts
Returns
Syntax
floor(number) number.floor()

Learn more about floor →


sqrt

Returns the positive square root of the number.

Accepts
Returns
Syntax
sqrt(number) number.sqrt()

Learn more about sqrt →


cbrt

Returns the cube root of the number.

Accepts
Returns
Syntax
cbrt(number) number.cbrt()

Learn more about cbrt →


exp

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

Accepts
Returns
Syntax
exp(number) number.exp()

Learn more about exp →


ln

Returns the natural logarithm of the number.

Accepts
Returns
Syntax
ln(number) number.ln()

Learn more about ln →


log10

Returns the base 10 logarithm of the number.

Accepts
Returns
Syntax
log10(number) number.log10()

Learn more about log10 →


log2

Returns the base 2 logarithm of the number.

Accepts
Returns
Syntax
log2(number) number.log2()

Learn more about log2 →


sign

Returns 1 if the number is positive, -1 if it is negative, and 0 if it is zero.

Accepts
Returns
Syntax
sign(number) number.sign()

Learn more about sign →


pi

Returns the ratio of a circle's circumference to its diameter.

Returns
Syntax
pi()

Learn more about pi →


e

Returns the base of the natural logarithm.

Returns
Syntax
e()

Learn more about e →


toNumber

Parses a number from text.

Accepts
Returns
Syntax
toNumber(value) value.toNumber()

Learn more about toNumber →


now

Returns the current date and time.

Returns
Syntax
now()

Learn more about now →


today

Returns the current date without the time.

Returns
Syntax
today()

Learn more about today →


minute

Returns the minute of the date (0-59).

Accepts
Returns
Syntax
minute(date) date.minute()

Learn more about minute →


hour

Returns the hour of the date (0-23).

Accepts
Returns
Syntax
hour(date) date.hour()

Learn more about hour →


day

Returns the day of the week of the date, between 1 (Monday) and 7 (Sunday).

Accepts
Returns
Syntax
day(date) date.day()

Learn more about day →


date

Returns the day of the month from the date (1-31).

Accepts
Returns
Syntax
date(date) date.date()

Learn more about date →


week

Returns the ISO week of the year of the date (1-53).

Accepts
Returns
Syntax
week(date) date.week()

Learn more about week →


month

Returns the month of the date (1-12).

Accepts
Returns
Syntax
month(date) date.month()

Learn more about month →


year

Returns the year of the date.

Accepts
Returns
Syntax
year(date) date.year()

Learn more about year →


dateAdd

Adds time to the date. The unit argument can be one of: "years", "quarters", "months", "weeks", "days", "hours", or "minutes".

Accepts
Returns
Syntax
dateAdd(date, num, unit) date.dateAdd(num, unit)

Learn more about dateAdd →


dateSubtract

Subtracts time from the date. The unit argument can be one of: "years", "quarters", "months", "weeks", "days", "hours", or "minutes".

Accepts
Returns
Syntax
dateSubtract(date, num, unit) date.dateSubtract(num, unit)

Learn more about dateSubtract →


dateBetween

Returns the difference between two dates. The unit argument can be one of: "years", "quarters", "months", "weeks", "days", "hours", or "minutes".

Accepts
Returns
Syntax
dateBetween(date, date, unit) date.dateBetween(date, unit)

Learn more about dateBetween →


dateRange

Returns a date range constructed from the start and end dates.

Accepts
Returns
Syntax
dateRange(start, end) start.dateRange(end)

Learn more about dateRange →


dateStart

Returns the start of the date range.

Accepts
Returns
Syntax
dateStart(dateRange) dateRange.dateStart()

Learn more about dateStart →


dateEnd

Returns the end of the date range.

Accepts
Returns
Syntax
dateEnd(dateRange) dateRange.dateEnd()

Learn more about dateEnd →


timestamp

Returns the current Unix timestamp, representing the number of milliseconds that have elapsed since January 1, 1970.

Accepts
Returns
Syntax
timestamp(date) date.timestamp()

Learn more about timestamp →


fromTimestamp

Returns the date from the given Unix timestamp.

Accepts
Returns
Syntax
fromTimestamp(timestamp) timestamp.fromTimestamp()

Learn more about fromTimestamp →


formatDate

Formats the date using a custom format string.

Accepts
Returns
Syntax
formatDate(date, format) date.formatDate(format)

Learn more about formatDate →


parseDate

An incredibly powerful addition, this function will convert an ISO 8601 string into a date object.

Accepts
Returns
Syntax
parseDate(dateText) dateText.parseDate()

Learn more about parseDate →


name

Returns the name of a person.

Accepts
Returns
Syntax
name(person) person.name()

Learn more about name →


email

Returns the email address of a person.

Accepts
Returns
Syntax
email(person) person.email()

Learn more about email →


at

Returns the value at the specified index in a list.

Accepts
Returns
Syntax
at(list, index) list.at(index)

Learn more about at →


first

Returns the first item in the list.

Accepts
Returns
Syntax
first(list) list.first()

Learn more about first →


last

Returns the last item in the list.

Accepts
Returns
Syntax
last(list) list.last()

Learn more about last →


slice

Returns the items of the list from the provided start index (inclusive) to the end index (optional and exclusive).

Accepts
Returns
Syntax
slice(list, startIndex, endIndex?) list.slice(startIndex, endIndex?)

Learn more about slice →


concat

Returns the concatenation of multiple lists.

Accepts
Returns
Syntax
concat(list, list2, ...) list.concat(list2, ...)

Learn more about concat →


sort

Returns the list in sorted order. Optionally, a provided expression can be used to determine the sorting order.

Accepts
Returns
Syntax
sort(list, expression?) list.sort(expression?)

Learn more about sort →


reverse

Returns the reversed list.

Accepts
Returns
Syntax
reverse(list) list.reverse()

Learn more about reverse →


join

Returns the values of the list with the joiner placed between each of the values.

Accepts
Returns
Syntax
join(list, joiner) list.join(joiner)

Learn more about join →


split

Returns a list of values created by splitting a string by a separator.

Accepts
Returns
Syntax
split(text, separator) text.split(separator)

Learn more about split →


splice

Removes a specified number of elements from a list at the startIndex and optionally inserts new elements at that position. If deleteCount is not provided, it defaults to 0.

Accepts
Returns
Syntax
splice(list, startIndex, deleteCount?, ...) list.splice(startIndex, deleteCount?, ...)

Learn more about splice →


unique

Returns the list of unique values in the input list.

Accepts
Returns
Syntax
unique(list) list.unique()

Learn more about unique →


includes

Returns true if the list contains the specified value, and false otherwise.

Accepts
Returns
Syntax
includes(list, search) list.includes(search)

Learn more about includes →


find

Returns the first element in the list for which the condition returns true.

Accepts
Returns
Syntax
find(list, condition) list.find(condition)

Learn more about find →


findIndex

Returns the index of the first item in the list for which the condition evaluates to true.

Accepts
Returns
Syntax
findIndex(list, condition) list.findIndex(condition)

Learn more about findIndex →


filter

Returns the values in the list for which the condition is true.

Accepts
Returns
Syntax
filter(list, condition) list.filter(condition)

Learn more about filter →


some

Returns true if any item in the list satisfies the given condition, and false otherwise.

Accepts
Returns
Syntax
some(list, expression) list.some(expression)

Learn more about some →


every

Returns true if every item in the list satisfies the given condition, and false otherwise.

Accepts
Returns
Syntax
every(list, condition) list.every(condition)

Learn more about every →


map

Returns the list populated with the results of calling the expression on every item in the input list.

Accepts
Returns
Syntax
map(list, expression) list.map(expression)

Learn more about map →


flat

Flattens a list of lists into a single list.

Accepts
Returns
Syntax
flat(list, list2?, ...) list.flat(list2?, ...)

Learn more about flat →


id

Returns the id of the page. If no page is provided, returns the id of the page the formula is on.

Accepts
Returns
Syntax
id(value?) value?.id()

Learn more about id →


equal

Returns true if both values are equal and false otherwise.

Accepts
Returns
Syntax
equal(value, value) value.equal(value)
Operator

==

Learn more about equal →


unequal

Returns false if both values are equal and true otherwise.

Accepts
Returns
Syntax
unequal(value, value) value.unequal(value)
Operator

!=

Learn more about unequal →


let

Assigns a value to a variable and evaluates the expression using that variable.

Accepts
Returns
Syntax
let(variable, value, expression) variable.let(value, expression)

Learn more about let →


lets

Assigns values to multiple variables and evaluates the expression using those variables.

Accepts
Returns
Syntax
lets(variable, value, variable2, value2, ..., expression) variable.lets(value, variable2, value2, ..., expression)

Learn more about lets →


count

Returns the number of elements in a list for which the condition is true. If no condition is provided, returns the total number of elements (equivalent to length()).

Accepts
Returns
Syntax
count(list, condition) list.count(condition)

Learn more about count →