How to Sum Values From Related Pages With a Formula
🔍 WiseChecker

How to Sum Values From Related Pages With a Formula

You have a Notion database where each page contains a number you want to total, and those pages are linked to a parent page through a relation property. Manually adding those numbers is slow and error-prone when the list grows beyond a few items. Notion does not have a built-in SUM function for related pages, but you can build a rollup formula that collects and adds the numbers automatically. This article explains how to create a formula property that sums numerical values from all pages linked through a relation.

Key Takeaways: Summing Related Page Values in Notion

  • Relation property: Links a parent database to a child database so each parent page can reference multiple child pages
  • Rollup property with Sum aggregation: Automatically adds all numbers from a number property in the related child pages
  • Formula property with sum() and map(): Combines values from a rollup array when you need custom logic before totaling

Understanding How Notion Handles Related Page Values

Notion databases store data in rows (pages) and columns (properties). When one page needs to reference data from another database, you use a relation property. A relation creates a link between a page in Database A and one or more pages in Database B. For example, an Invoice page can be linked to multiple Line Item pages that each contain a Price number property.

To sum the Price values from all Line Items linked to a single Invoice, Notion provides two paths:

Rollup Properties: The Direct Method

A rollup property reads a property from every related page and applies an aggregation function, such as Sum, Average, Count, Min, or Max. Rollups are the simplest way to total numbers from related pages. You do not write any formula code. The rollup automatically updates when you add or remove related pages or change their values.

Formula Properties with sum() and map(): The Custom Method

When you need more control, such as filtering which related pages to include or applying a multiplier before summing, you use a formula property. Notion formulas can call the sum() function on an array of numbers. To get that array from a rollup, you first create a rollup property set to Show Original (not Sum) so it returns a list of values. Then your formula uses map() and sum() to process the list.

Steps to Sum Values From Related Pages

The following steps assume you already have two databases linked by a relation. If you do not, create the relation first. In this example, Database A is named Invoices and Database B is named Line Items. The Line Items database contains a Number property called Price.

  1. Create the relation property in the parent database
    Open the Invoices database. Click the + button in the top-right corner of the table header. Choose Relation from the property type list. Name the property Line Items. In the dialog that appears, select the Line Items database. Click Create Relation. Notion adds a new column that lets you link any number of Line Item pages to each Invoice page.
  2. Link child pages to the parent page
    Click inside the Line Items relation cell on any Invoice page. A dropdown shows all pages in the Line Items database. Click each Line Item you want to link. The cell shows the linked pages as blue badges. Repeat this for every Invoice that needs summed values.
  3. Add a Rollup property for simple summing
    Click the + button in the table header again. Choose Rollup from the property type list. Name the property Total Price. In the Relation field, select Line Items (the relation you created). In the Property field, select Price (the Number property in Line Items). In the Calculate field, select Sum. Click Save. The Total Price column now shows the sum of all Price values from linked Line Items.
  4. Create a Rollup with Show Original for custom formulas
    If you need a custom formula later, you need the raw list of values. Add a second rollup property named Raw Prices. Set Relation to Line Items and Property to Price. In the Calculate field, select Show Original. This rollup returns an array like [25, 40, 15] instead of a single number.
  5. Write a formula that uses the raw array
    Add a Formula property and name it Custom Total. Click Edit Formula. Enter the following code:
    sum(prop("Raw Prices").map(current, current 1.1))
    This formula multiplies each Price by 1.1 (adding a 10% tax) and then sums the results. Click Save. The Custom Total column shows the tax-inclusive sum.
  6. Test the formula with sample data
    Add three Line Item pages with Price values 100, 200, and 300. Link them to one Invoice. The Total Price rollup shows 600. The Custom Total formula shows 660. Change one Price to 150. Both values update automatically.

If the Sum Formula Still Does Not Work Correctly

Rollup shows 0 even though child pages have numbers

The most common cause is a mismatch in property types. The rollup Property field must point to a Number property, not a Text or Select property. Open the child database and confirm the Price property is set to Number. Also check that the relation is correctly pointing to the child database and that at least one child page is linked to the parent page.

Formula errors when using map() on a rollup

If the rollup is set to Sum instead of Show Original, the formula receives a single number, not an array. The map() function expects an array. Change the rollup Calculate field to Show Original. If the rollup contains empty values, wrap the map function with a filter: prop("Raw Prices").filter(current, current != empty).map(current, current 1.1).

Values do not update after changing child page data

Notion recalculates rollups and formulas when you edit a property on the child page. If the formula does not update, refresh the browser page (F5) or reload the parent database. If the problem persists, remove and re-add the rollup property. This clears any cached data.

Sum includes values from unrelated pages

A rollup sums all pages linked through the relation. If a child page is linked to multiple parent pages, its value is included in every parent’s total. To avoid double-counting, ensure each child page belongs to only one parent, or use a formula with a filter that checks a condition on the child page, such as a status property.

Rollup vs Formula: How Each Method Sums Related Values

Item Rollup with Sum Formula with map() and sum()
Setup time Under 1 minute; no code 2-3 minutes; requires writing formula
Custom logic None; only standard aggregations Supports multiplication, filtering, conditional logic
Handles empty values Automatically ignores empty cells Requires explicit filter or empty check
Performance on large datasets Fast; cached by Notion Slower if many child pages; recalculates per parent
Use case Straight sum of all linked numbers Sum with tax, discount, or conditional inclusion

You can now sum values from related pages using either a rollup or a formula. Start with a rollup set to Sum for the quickest result. If you need custom calculations such as applying a tax rate or only summing pages with a certain status, use a formula with map() and sum() on a Show Original rollup. For complex filtering, combine the formula with a filter() function to exclude unwanted child pages.