Notion Formula
Notion provides formula to dynamically calculate the value of a specific cell for a database.
If you navigate to your devtools and inspect the data, you'll see that this is how notion stores formula data. Lets take a look at an example of a simple notion formula:-
#
Parts of a formula argumenttype
: This is thetype
of the formula argument, which could have the valuesfunction | symbol | constant | property | operator
.result_type
: The computated type of the argument, which has the following valuestext | checkbox | date | number
.name
: Indicates either a property, operator,function or symbol name, this is absent in constanttype
#
Formula Argument Result typeBased on an arguments result_type
it can be divided into the following types:
checkbox
: This sort of arguments return a boolean value.text
: This sort of arguments return a string value.date
: This sort of arguments return a date valuenumber
: This sort of arguments return a number value, which could either be integer or float.
#
Formula argument variantsBased on an arguments type
it can be divided into the following types:
- Symbol: A formula argument which is used to indicate fixed constant values like
true
,false
,e
andpi
- Property: A formula argument which is used to reference the value of another property of the schema
- Constant: A formula argument which is used to indicate a literal constant value like a number or a text.
- Function: A formula argument which is used to create a function.
- Operator: A separate representation of functions, by using symbols like
+
,-
instead ofadd
andsubtract
respectively.
All variants have result_type
Each of the variants return an argument of a specific result_type
.
#
Property Reference ArgumentThe computed value of a property can be used as a formula argument. Inside notion it works by using the schema unit name inside the prop
function, eg prop("Title")
, would return the value stored in that cell.
This is how notion stores a property formula argument
Schema unit type coercion
Even though there are multiple schema unit types, all of them are coerced into the types supported by the result_type
.
#
Nested Function ArgumentFunctions gives formulas superpowers and thus notion provides a handful of them. Visit notion functions, to learn in details about everything function.
This is how notion stores a function formula argument
#
Constant Literal ArgumentA formula argument which is used to indicate a literal constant value like a number or a text.
Different from Symbol
Constants are different from symbols as symbols can only contain four possible values, while constants con contain infinity variants of values
This is how notion stores a constant formula argument
#
Operator Function ArgumentA separate representation of functions, by using operators like +
, -
instead of keywords like add
and subtract
respectively. Internally all operators except for the ternary operator ?:
maps to a function.
This is how notion stores a constant formula argument
#
Symbol Literal ArgumentA formula argument which is used to indicate fixed constant values like true
, false
, e
and pi
It contains the following values:-
true
: A checkbox rt symbol, with nametrue
false
: A checkbox rt symbol with namefalse
e
: A number rt symbol with namee
pi
: A number rt symbol with namepi
This is how notion stores a symbol formula argument
#
Variants of formula argumentsDue to the existence of result_type
and type
, the following variants of arguments arises
type
variants#
Number x - number x symbol: A
symbol
type
argument that returnsnumber
asresult_type
. Eg:e | pi
- number x constant: A
symbol
type
argument that returnsnumber
asresult_type
. Eg:1 | 10
- number x property: A
property
type
argument that returnsnumber
asresult_type
. Eg:prop("Number")
- number x function: A
property
type
argument that returnsnumber
asresult_type
. Eg:abs(1)
- number x operator: A
property
type
argument that returnsnumber
asresult_type
. Eg:1 + 1
type
variants#
Text x - text x constant: A
constant
type
argument that returnstext
asresult_type
. Eg:"1" | "a"
- text x property: A
property
type
argument that returnstext
asresult_type
. Eg:prop("Text")
- text x function: A
property
type
argument that returnstext
asresult_type
. Eg:concat("a", "b")
- text x operator: A
property
type
argument that returnstext
asresult_type
. Eg:"b" + "a"
No symbol for text
Text result_type
arguments does not have a symbol
type
type
variants#
Checkbox x - checkbox x symbol: A
symbol
type
argument that returnscheckbox
asresult_type
. Eg:true | false
- checkbox x property: A
property
type
argument that returnscheckbox
asresult_type
. Eg:prop("Checkbox")
- checkbox x function: A
property
type
argument that returnscheckbox
asresult_type
. Eg:and(true, false)
- checkbox x operator: A
property
type
argument that returnscheckbox
asresult_type
. Eg:true and false
No constant for text
Checkbox result_type
arguments does not have a constant
type
type
variants#
Date x - date x property: A
property
type
argument that returnsdate
asresult_type
. Eg:prop("Date")
- date x function: A
property
type
argument that returnsdate
asresult_type
. Eg:now()
No constant,symbol for date
Date result_type
arguments does not have constant
and symbol
variants