toNumber
Learn how to use the toNumber function in Notion formulas.
1
toNumber(string)
2
toNumber(Boolean)
3
toNumber(date)
Good to know: If a string starts with a number and contains letter chracters as well,
toNumber()
will return just that starting number. However, if the string does not start with a number, toNumber()
will output nothing – even if the string contains a number elsewhere.1
toNumber("42") // Output: 42 (number)
2
3
toNumber("42 rabbits jump 100 times") // Output: 42
4
5
toNumber("I have 42 rabbits.") // Output: blank
6
7
toNumber(true) // Output: 1
8
9
toNumber(false) // Output: 0
10
11
toNumber(5>3) // Output: 1
12
13
toNumber(now()) // Output: 1655757000000 (changes with now()'s value)
This example database is a simple habit tracker. Each property represents a different habit, and the Habits formula property adds them up and outputs a string reporting the number of habits completed on that day.

1
// Compressed
2
format(toNumber(prop("💧")) + toNumber(prop("🏃♂️")) + toNumber(prop("🏋️♀️")) + toNumber(prop("🥦"))) + "/4" + if((toNumber(prop("💧")) + toNumber(prop("🏃♂️")) + toNumber(prop("🏋️♀️")) + toNumber(prop("🥦"))) == 1," Habit"," Habits")
3
4
// Expanded
5
format(
6
toNumber(
7
prop("💧")
8
) +
9
toNumber(
10
prop("🏃♂️")
11
) +
12
toNumber(
13
prop("🏋️♀️")
14
) +
15
toNumber(
16
prop("🥦")
17
)
18
) +
19
"/4" +
20
if(
21
(
22
toNumber(
23
prop("💧")
24
) +
25
toNumber(
26
prop("🏃♂️")
27
) +
28
toNumber(
29
prop("🏋️♀️")
30
) +
31
toNumber(
32
prop("🥦")
33
)
34
) == 1,
35
" Habit",
36
" Habits"
37
)
Finally, an if statement uses the same process to determine if the total number of habits completed is equal to
1
. If so, it outputs “Habit”; if not, it outputs the plural “Habits”.
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 4mo ago