The min()
function returns the smallest of one or more numbers. min()
accepts only numbers or properties that output numbers (it will not auto-convert Booleans).
min(number)
min(number, number)
min(number, number, ...)
Code language: JavaScript (javascript)
Note that the dot notion version can only be used with a list of numbers as the first argument, and optional numbers or lists of numbers as the second argument.
Using min()
with no arguments will return Infinity
.
Example Formulas
min(4, 1, 9, -3) /* Output: -3 */
/* Assume prop("Num") contains 3 */
[prop("Num"), 13, 5].min() /* Output: 3 */
[1, 2, 3].min(4, 5) /* Output: 1 */
/* Other data types must be converted to number */
min(3, 8, toNumber(false)) /* Output: 0 */
/* Here, toNumber() is used to convert false to a number (0) */
Code language: JavaScript (javascript)
Good to know: min()
and max are useful for finding maximum and minimum values across multiple properties. They’re not useful for finding max/min values across multiple database rows.
For that, you’ll want to associate the rows to another common row via a Relation, then use a Rollup to calculate the max value among them. Here’s a small example database.
This approach still has limitations, but since Notion hasn’t provided a true query language for its database feature, it’s the best we can currently do (unless you create an external tool via the official API).
Example Database
The example database below contains quarterly sales data for a fictional company. The Min property displays the dollar amount from the worst quarter, while the Worst Quarter property displays which quarter had the worst performance.
View and Duplicate Database
“Min” Property Formula
min(prop("Q1"), prop("Q2"), prop("Q3"), prop("Q4"))
Code language: JavaScript (javascript)
min()
accepts numbers or number properties.
Here, we simply pass each quarter’s property to the min()
function in order to find the minimum quarterly sales value.
“Worst Quarter” Property Formula
if(
prop("Q1") == prop("Min"),
"Q1",
if(
prop("Q2") == prop("Min"),
"Q2",
if(
prop("Q3") == prop("Min"),
"Q3",
"Q4"
)
)
)
Code language: JavaScript (javascript)
Here’s an example of how we can make min()
more useful.
Using a nested if statement, we compare the numeric value of each quarter property to that of the Min property.
If a quarter’s value matches that of the Min property, we output that quarter’s name.