Loading [MathJax]/extensions/tex2jax.js

mod

Learn how to use the mod (%) operator to obtain a remainder in Notion formulas.

The remainder (%) operator allows you to get the remainder after dividing the first operand with the second operand.

number % number

mod(number, number)

number.mod(number)
Code language: JavaScript (javascript)

Notion provides a mod() function as well as the % operator (I’ll just reference % for the rest of this article).

Somewhat confusingly, these do not return a true modulus value; they return a remainder (see: Remainder or Modulus? below).

As % and mod() output a remainder, their output values will take the sign (+/-) of the dividend.

For reference, the dividend is the number being divided by the divisor, which produces the quotient:

\(\frac {dividend}{divisor} = quotient\)
19 % 12 /* Output: 7 */

19 mod 12 /* Output: 7 */

mod(-19, 12) /* Output: -7 */

-19.mod(12) /* Output: -7 */
Code language: JavaScript (javascript)

As of the Formulas 2.0 update in 2023, if the divisor is negative, both mod() and % will now treat it as a negative integer natively. This is a change from the pre-Formulas 2.0 behavior.

19 % (-12) /* Output: 7 */

/* prop("negative num") == -12 */
19 % prop("negative num") /* Output: 7 */

19 % -12 /* Output: 7 */

mod(19, -12) /* Output: 7 */
Code language: JavaScript (javascript)

Just as in JavaScript, Notion’s % operator calculates the remainder of two numbers, not the modulus. Confusingly, the mod() function does this as well, despite its name.

The remainder and modulus of two numbers will be identical when both the dividend and divisor have the same sign (+/-). If their signs differ, however, the modulus will differ from the remainder.

These two articles explain this well:

You can prove this using WolframAlpha:

  • -19 mod 12 results in 5
  • QuotientRemainder[-19,12] results in -7

To calculate a true modulus in Notion, use ((x % y) + y) % y instead:

// Using the % operator
((19 % 12) + 12) % 12

// Using the mod() formula
mod(mod(19, 12) + 12, 12)
Code language: JavaScript (javascript)

This example database shows the differing outputs of remainder and true modulus expressions.

Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.
A new tool that blends your everyday work apps into one. It’s the all-in-one workspace for you and your team
thomasfrank.notion.site

You can check these results here:

Modulo Calculator
Modulo calculator finds a mod b, the remainder when a is divided by b. The modulo operation returns the remainder in division of 2 positive or negative numbers or decimals.
www.calculatorsoup.com
prop("Dividend") % prop("Divisor")
Code language: JavaScript (javascript)
(prop("Dividend") % prop("Divisor") + prop("Divisor")) % prop("Divisor")
Code language: JavaScript (javascript)

Instead of using hard-coded numbers, I’ve called in each property using the prop() function.

About the Author

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.