Notion formulas can pull values from a related database, but applying the min() or max() function to sub-items within that relation is not obvious. The min() and max() functions work on a list of numbers in the same database, not directly on values from a related table. This article explains how to use rollups combined with formula properties to calculate the minimum or maximum value from sub-items in a relation.
Key Takeaways: Using min() and max() With Relation Sub-Items
- Rollup property with min or max aggregation: Create a rollup in the parent database that picks a number field from the related database and sets the aggregation to Min or Max.
- Formula referencing the rollup: Write a formula in the parent database that uses the rollup value as a single number, not as a list.
- No direct min() or max() on relation values: The formula min() and max() functions cannot iterate over related sub-items; you must use a rollup first.
Why Notion Cannot Use min() or max() Directly on Relation Sub-Items
The min() and max() functions in Notion formulas work only on a list of numbers that exist within the same database row or on a list generated by the formula itself. When you have a relation property that links to another database, the relation does not produce a list of numbers; it produces a list of page references. The formula engine cannot convert those references into numbers without an intermediate step.
To get a numeric value from a related page, you must use a rollup property. A rollup can pull a value from a related page and then apply an aggregation function like Min, Max, Sum, Average, Count, or Show Original. After the rollup is created, the formula can reference that rollup as a single number. The formula does not need to call min() or max() again because the rollup already performed that operation.
Steps to Calculate the Minimum or Maximum From Related Sub-Items
The following steps assume you have two databases connected by a relation. The parent database contains the relation property. The related database (sub-items) contains a number property that you want to evaluate.
- Create a rollup property in the parent database
Open the parent database and click the + icon in the properties header. Select Rollup from the property type menu. Name the rollup, for example “Min Price” or “Max Score.” - Configure the rollup relation and property
In the rollup configuration, set the Relation field to the relation property that links to the sub-items database. Set the Property field to the number property in the sub-items database that you want to aggregate. Leave the Aggregation dropdown at its default unless you want a specific function — for min or max, change it to Min or Max. - Verify the rollup output
After saving, the rollup property will display a single number. If no sub-items exist, the rollup shows “No items.” If the sub-items have the chosen number property empty, the rollup may show 0 or remain blank depending on the aggregation. - Create a formula property that references the rollup
Add a new formula property in the parent database. In the formula editor, type the rollup property name exactly as it appears. For example, if the rollup is named “Min Price,” writeprop("Min Price"). The formula now uses that single number value. - Apply additional calculations in the formula
You can now perform arithmetic on that number. For example, to show a discount of 10 percent off the minimum price, writeprop("Min Price") 0.9. The formula treats the rollup as a number, not a list.
Common Mistakes and Limitations When Using min() and max() With Relations
Formula shows “No items” or blank when sub-items exist
This happens when the rollup property’s aggregation is set to “Show Original” instead of Min or Max. Show Original returns the raw value from the first related page, which may be empty if the first page has no value. Change the aggregation to Min or Max to force the rollup to evaluate all related pages.
Formula returns 0 when sub-items have no numeric value
If the related sub-items have the target property set to empty, the rollup may treat that as 0, especially with the Sum or Average aggregation. To avoid this, ensure all sub-items have a numeric value in the target property. Alternatively, use the Min or Max aggregation, which ignores empty values unless all values are empty.
Trying to use min() or max() directly on a relation property
Writing min(prop("Related Items").Price) does not work because the relation property does not expose a list of numbers. The formula engine cannot access sub-properties of related pages. Always create a rollup first, then reference the rollup in the formula.
Rollup Aggregation Options for Sub-Item Calculations
| Aggregation | What It Returns | Best Use Case |
|---|---|---|
| Show Original | Value from the first related page | When only one sub-item exists or you want the first match |
| Min | Smallest numeric value across all related pages | Finding the lowest price, earliest date, or smallest score |
| Max | Largest numeric value across all related pages | Finding the highest price, latest date, or highest score |
| Average | Mean of all numeric values | Calculating average rating or average cost |
| Sum | Total of all numeric values | Adding up expenses, hours, or quantities |
| Count | Number of related pages | Counting sub-items regardless of numeric values |
| Count All | Number of related pages including those with empty values | When you need an exact count even if some values are blank |
| Count Values | Number of related pages that have a value in the target property | Counting only sub-items that have data |
| Count Unique Values | Number of distinct values across related pages | Identifying how many different prices or categories exist |
| Percent Empty | Percentage of related pages with an empty target property | Checking data completeness |
| Percent Not Empty | Percentage of related pages with a non-empty target property | Checking data completeness |
Conclusion
You can now calculate the minimum or maximum value from related sub-items in Notion by combining a rollup property with a formula. The rollup performs the aggregation and returns a single number, which the formula can then use in arithmetic or conditional expressions. To speed up future setups, duplicate a database template that already contains the rollup and formula properties. For advanced use, try nesting rollups across multiple relation levels by creating a chain of rollups from the deepest sub-items upward.