Links

# unaryMinus

Learn how to use the unaryMinus (-) operator in Notion formulas.
The unaryMinus (`-`) operator negates a number.
1
-number
2
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.

## Example Formulas

1
-42 // Output: -42
2
3
-(-42) // Output: 42
4
5
unaryMinus(42) // Output: -42

### Expressing Negative Values

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.
1
19 % -12 // Outputs incorrect value of -11.81
2
19 % (-12) // Correctly outputs 7
3
4
// Negative value passed via a property does not need to
5
// be wrapped in () symbols
6
7
prop("negative num") == -12
8
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.

### Type Conversion with unaryPlus

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).
1
-+"42" // Output: -42
2
3
-+"-42" // Output: 42
4
5
-+true // Output: -1
6
7
-toNumber(now()) // Output: -165479808000 (will change with now()'s timestamp)

## Example Database

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.

### "Abs" Property Formula

1
// Compressed
2
3
if(prop("Num 1") - prop("Num 2") < 0, -(prop("Num 1") - prop("Num 2")), prop("Num 1") - prop("Num 2"))
4
5
// Expanded
6
7
if(
8
prop("Num 1") - prop("Num 2") < 0,
9
-(
10
prop("Num 1") - prop("Num 2")
11
),
12
prop("Num 1") - prop("Num 2")
13
)
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.

#### 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.
Last modified 4mo ago