Hey everyone! I’m trying to figure out how to add up all the ‘quantity’ values from related items in my Notion database. Here’s what I’m dealing with:
I have two databases. The first one has items with a ‘Quantity’ property. The second database has a relation to the first one, and I want to create a formula that adds up all the quantities from the related items.
For example, if I have two related items with quantities 6 and 4, I want the formula to give me 10.
I know I can get the quantity of the first related item using something like prop("Relation A").first().prop("Quantity"), but I’m stumped on how to add up all of them.
Any ideas on how to loop through all the related items and sum their quantities? Thanks for your help!
hey, i ran into this too. use a rollup property in your second database to sum the related quantities. notion doesn’t support direct summation in formulas, so the rollup trick is the best workaround.
I’ve dealt with this exact issue in my project management database. Here’s what worked for me:
Instead of trying to create a complex formula, I used a Rollup property in the second database. It’s much simpler and more efficient.
Set up the Rollup to reference your relation property, then choose ‘Sum’ as the calculation type and select the ‘Quantity’ field. This automatically totals all the quantities from the linked items.
One caveat: Rollups have a 1000 item limit. If you’re working with larger datasets, you might need to segment your data or look into using the Notion API for more robust calculations.
This approach has saved me hours of frustration and works seamlessly. Hope it helps you too!
I’ve been working with Notion databases extensively, and I can tell you that summing up related quantities isn’t straightforward with built-in formulas alone. However, there’s a workaround using Rollup properties that might solve your problem.
Create a Rollup property in your second database that references the relation to the first database. Set the calculation to ‘Sum’ and choose the ‘Quantity’ property. This will automatically sum all the quantities from the related items.
If you need this sum in a formula, you can then reference the Rollup property. It’s not as direct as looping through items, but it’s effective and updates dynamically. Keep in mind that Rollups have a limit of 1000 items, so if you’re dealing with larger datasets, you might need to explore other solutions like the Notion API.