unaryMinus

Learn how to use the unaryMinus (-) operator in Notion formulas.

The unaryMinus (-) operator negates a number.

-number unaryMinus(number)

Unary negation negates a number; it does not simply make it negative. This means you can use it to make a negative number positive.

This is useful to keep in mind since unaryPlus does not make a number positive; it converts non-numeric data to a number.

You can also use the function version, unaryMinus().

Good to know: A unary operator only has a single operand, while a binary operator has two. unaryMinus and unaryPlus are, as their names imply, unary operators. Examples of binary operators include add, divide, pow, etc.

-42 // Output: -42 -(-42) // Output: 42 unaryMinus(42) // Output: -42

It’s important to know that Notion’s formula editor will sometimes interpret the - symbol as a unaryMinus in situations where you’re trying to express a truly negative value.

This can happen with the mod (%) operator when the divisor is a hard-coded negative number.

19 % -12 // Outputs incorrect value of -11.81 19 % (-12) // Correctly outputs 7 // Negative value passed via a property does not need to // be wrapped in () symbols prop("negative num") == -12 19 % prop("negative num") // Output: 7

As shown in the code block above, this does not apply to negative values passed via a property. Those values will be truly negative since a property can’t add a unaryMinus operator (or any operator) to your formula.

You can read more about this distinction in the Negative Divisors section of the mod article.

Good to know: Parentheses () have the highest operator precedence in Notion formulas, so you can avoid all sorts of confusion by using them to make the order of your formula’s operation explicitly defined.

Unlike in JavaScript, unaryMinus does not convert other data types (such as strings or Booleans) to numbers in Notion.

However, you can combine it with unaryPlus to quickly convert a numeric string or boolean to a number. You can also combine it with toNumber, which can convert dates to numbers (unaryPlus cannot do this).

-+"42" // Output: -42 -+"-42" // Output: 42 -+true // Output: -1 -toNumber(now()) // Output: -165479808000 (will change with now()'s timestamp)

The table below uses unaryMinus with an if statement to create a manual absolute value function. Notion comes with abs, so building this is just useful as a proof-of-concept.

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
// Compressed if(prop("Num 1") - prop("Num 2") < 0, -(prop("Num 1") - prop("Num 2")), prop("Num 1") - prop("Num 2")) // Expanded if( prop("Num 1") - prop("Num 2") < 0, -( prop("Num 1") - prop("Num 2") ), prop("Num 1") - prop("Num 2") )

This formula checks whether the difference between Num 1 and Num 2 is less than zero. If it is, it applies the - operator to the entire equation in order to get the absolute value.

Other formula components used in this example

if – Thomas Frank
thomasjfrank.com
smaller – Thomas Frank
thomasjfrank.com
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.

🤔 Have an UB Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas

🤔 Have a Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas