How to calculate total of property values across related items in Notion formula

I’m trying to create a formula in Notion that will add up all the values from a specific property across multiple related records. I have two databases connected through a relation.

In my setup, Database A contains records with a property called “Amount” that has numeric values (like 8 and 3). Database B has a relation to Database A and I want to create a formula column that calculates the total of all “Amount” values from the related records.

I know I can get individual items using prop("My Relation").first().prop("Amount") which returns the first value, or I can use .last() to get the final one. The relation property prop("My Relation") gives me an array of connected records.

The problem is I can’t figure out how to loop through every item in the related database to sum all the “Amount” values together. Is there a way to iterate through the entire array and calculate the total? Any help would be great!

rollups are def the way to go! formulas in notion just cant do array stuff. just go to db B, add a rollup prop, select your relation, and set it to “sum”. trust me, this is the only reliable method from all the things i tried.

Hit the same wall when I moved my inventory to Notion last month. Rollups are great for basic sums, but they’re useless when you need conditional logic or different calculations for specific records. Here’s what worked for me - set up a formula in Database A that handles your conditional calculations first, then use a rollup in Database B to sum those results. Way more control over what actually gets totaled. Say you only want amounts over $100 or need different multipliers based on status - handle all that in the Database A formula first. Then the rollup just adds up those processed values instead of raw numbers. Takes more setup time but beats using external tools.

Unfortunately, Notion formulas can’t do loops or iteration like real programming languages. The formula system just isn’t built for processing arrays of related records, so what you’re trying to do with summing across relations won’t work with a formula column. Here’s the workaround most people use: ditch the formula and create a rollup property instead. In Database B, add a new property and pick “Rollup” as the type. Choose your relation property, select “Amount” as the property to roll up, then set the calculation to “Sum.” It’ll automatically total all the Amount values from your related records and updates whenever your data changes. Way more reliable than trying to force a formula to work.

Rollups work fine until you need those calculations to trigger other workflows or sync with external tools.

I hit this exact problem building expense tracking across multiple Notion databases. Rollups break down when you need totals to auto-update spreadsheets, send budget alerts, or feed into other systems.

Latenode solved it for me. I set up automation that watches Database A for changes, grabs related records, calculates sums with custom logic, then updates Database B automatically.

You get proper error handling, conditional calculations rollups can’t handle, and instant syncing across connected tools. Plus you can trigger actions based on totals - like Slack notifications when amounts hit thresholds.

Way more flexible than Notion’s built-in limits.

The Problem: You’re trying to perform complex calculations across related records in Notion, and you’re finding that Notion’s built-in formulas and rollups are insufficient for your needs. You need a more flexible and robust solution to handle these calculations, potentially involving conditional logic or integration with external tools.

:thinking: Understanding the “Why” (The Root Cause):

Notion’s formula system has limitations when dealing with arrays and complex relational data. While rollups are helpful for simple aggregations, they lack the flexibility needed for sophisticated calculations or integration with other systems. The limitations stem from the design of Notion’s formula engine, which isn’t built for iterative processing or advanced conditional logic in the same way a general-purpose programming language is. Attempting to force complex calculations into Notion’s formula system often leads to cumbersome workarounds or outright failure.

:gear: Step-by-Step Guide:

  1. Leverage External Automation: The most effective solution for complex calculations across related Notion databases is to use an external automation tool. This allows you to bypass Notion’s formula limitations and implement custom logic using a full-fledged programming language. This approach offers superior control, flexibility, and the ability to integrate seamlessly with other tools.

  2. Choose an Automation Platform: Select an automation platform designed to integrate with the Notion API. These platforms typically provide a visual interface or scripting capabilities to create workflows that interact with your Notion databases. These workflows will fetch data, perform your calculations, and update your target database.

  3. Develop Your Automation Workflow: Build a workflow that performs the following:

    • Fetch Data: Retrieve the relevant records from Database A using the Notion API.
    • Process Data: Implement your custom calculations, including any conditional logic needed, using the chosen platform’s scripting capabilities or visual workflow builder.
    • Update Database B: Update the necessary properties in Database B with the calculated results using the Notion API.
  4. Handle Errors and Rate Limits: Implement robust error handling to gracefully manage API request failures (network issues, rate limits, permission denials), and incorporate mechanisms to avoid exceeding the Notion API’s rate limits. Exponential backoff strategies are beneficial here.

  5. Monitor and Refine: After deploying your automation, monitor its performance and refine your workflow as needed.

:mag: Common Pitfalls & What to Check Next:

  • API Key/Token: Double-check your Notion API integration token. Incorrect tokens will lead to authentication errors.
  • Rate Limiting: Implement rate-limiting safeguards in your automation to prevent exceeding the Notion API’s limits. Notion provides documentation on their API rate limits; respect these limits to avoid being throttled.
  • Data Consistency: Ensure that your automation handles data inconsistencies gracefully. Consider edge cases, such as missing or invalid data in your Notion databases.
  • Notion API Version: Make sure your automation is compatible with the current version of the Notion API.

:speech_balloon: Still running into issues? Share your (sanitized) config files, the exact command you ran, and any other relevant details. The community is here to help!

Been using Notion databases for business tracking for three years. Hit this same formula limitation early on with expense calculators. Everyone’s right about rollups, but watch the direction - create the rollup property in Database B and point it at Database A through your existing relation. Rollups sometimes show zero if the relation isn’t bidirectional. Check that your Database A relation also shows connected records from Database B. Rollups handle empty Amount fields way better than formulas too - they’ll just skip them instead of breaking everything.

Had this exact problem building a project tracker last year. Notion’s formula limits are annoying when you’re trying to aggregate relational data. Rollups are the usual fix, but here’s a workaround if you need more flexibility. Create a formula in Database A that references Database B, then use a rollup in Database B to sum those calculated values. This roundabout method lets you do complex calculations before aggregating. One more thing - if your related records change a lot, rollups update automatically while formulas sometimes need manual refresh. But honestly, the rollup approach is still your best bet for basic summation across relations.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.