Formula Components

Formulas and Databases

Reference

Formula Examples

ceil

Learn how to use the ceil function in Notion formulas.

The

`ceil()`

function returns the smallest integer that is greater than or equal to its argument.1

ceil(number)

In other words,

`ceil()`

rounds a non-whole number to the next largest integer. When used on an integer, it will return that integer.1

ceil(4.2) // Output: 5

2

β

3

ceil(3.845) // Output: 4

4

β

5

ceil(4) // Output: 4

6

β

7

// Calculate the donated change in a round-up donation

8

// Assume prop("Subtotal") is $5.34

9

ceil(prop("Subtotal")) - prop("Subtotal")

10

// Output: $0.66

Itβs worth noting that

`ceil()`

rounds βupward towards positive infinityβ, while its counterpart, floor, rounds βdownward towards negative infinityβWhen a negative value is passed as

`ceil()`

's argument, youβll still get a greater value.1

ceil(-3.7) // Output: -3

`ceil()`

In JavaScript, the Math.trunc function rounds βtowardsβ zero. It simply removes all decimal values from a non-whole number - e.g.

`Math.trunc(3.7) == 3`

and `Math.trunc(-3.7) == -3`

.1

// Assume a number property exists called Num

2

prop("Num") >= 0 ? floor(prop("Num")) : ceil(prop("Num"))

Stores often ask customers if they would like to make a donation to charity along with their purchase.

This example database calculates donations based on four possible options - **$1, $5, Round-Up,** and **no donation**.

A βround-upβ donation simply rounds the purchase sub-total to the next greatest whole dollar, and donates the change.

ceil

College Info Geek on Notion

1

// Compressed

2

if(contains(prop("Donation Choice"),"quot;),toNumber(replaceAll(prop("Donation Choice"),"[^\\d]","")),if(prop("Donation Choice") == "Round-Up",ceil(prop("Subtotal")) - prop("Subtotal"),0))

3

β

4

// Expanded

5

if(

6

contains(

7

prop("Donation Choice"),

8

"quot;

9

),

10

toNumber(

11

replaceAll(

12

prop("Donation Choice"),

13

"[^\\d]",

14

""

15

)

16

),

17

if(

18

prop("Donation Choice") == "Round-Up",

19

ceil(prop("Subtotal")) - prop("Subtotal"),

20

0

21

)

22

)

The **Donation Choice** select property models multiple-choice buttons that customers may press on a point-of-sale system.

This formula calculates the donation based on the customerβs choice of **$1, $5, Round-Up**, or **no donation.**

A nested if statement is used to check which option was chosen, and to execute different logic depending on the choice.

First, the contains function is used to check if the choice contains **$1** or **$5**.

`$`

. If so, we know that the choice was either Since Select options are strings by default, we use replaceAll and a small regular expression to remove any non-numeric character from that string (

`[^\\d]`

translates to βany character that isnβt a digitβ). If so, we use

`ceil()`

to find the amount of change donated in the round-up donation: `ceil(prop("Subtotal")) - prop("Subtotal")`

.Finally, if the

`None`

option was chosen, we set the donation to `$0`

.β 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 21d ago

Copy link

On this page

Example Formulas

Negative Values

Example Database

View and Duplicate Database

βDonationβ Property Formula