Calculating the sum of fields in a repeating group

First the forum page is not opening for me from my laptop (different ips and different browsers) works only from mobile - is it only me or someone else has this ?

Now my question is what’s the best way to calculate the sum of certain fields In a repeating group , lets say the type contains a field total amount and there are 100 records in the database. How to calculate the sum of all total amounts ? I guess it can be done by converting the search result into a list? But then there is a limit of 1000 records.
Please advise

Ok i found a way to calculate the sum with math.js - see a screenshot below, but it takes a few seconds to do the math even for a few records, I imaging that it would be difficult for large operations. Isn’t it possible to implement these math operations through “calculate formula” function in Bubble?

3 Likes

Definitely at some point, probably not the first thing on the list though.

Hey @levon

Did you have any progress on this. What do you use now? How do you handle this?

I"m mostly using the :sum operation which is built in Bubble. for that first you do a search for the a certain type, then a certain field which has a filedtype - number, and then you can add :sum to the end of that search and it will sum up all those fields together.

Thanks,
Levon.

Founder at Bubblewits - Bubble Certified Partner

http://bubblestore.io – a place to buy Bubble templates for landing pages, workflows etc.
http://iambubble.com - one page Bubble demo
http://builtonbubble.com - Collection of apps built on Bubble

5 Likes

Thanks

Hi,

Can you help me with this please? I’m having the same issue, but I didnt understand the answer. I want the total of prices in a repeating group. When I do the search for, this is all I get

I’m also looking for this. I have records that I have the same name, I want to sum their quantities, by item.

Item A, quantity is 10
Item B, quantity is 1
Item A, quantity is 11

Should just display two items:
Item A, quantity is 21
Item B, quantity is 1

1 Like

In order to get the sum option, the field type must be a number not text.

Then you’ll select the values and place sum at the end, sorry not currently in front of the app so I can’t send you screenshots

If you look at the first screenshot I sent, you will see the sum option once the field type is a number.

An example: assuming the data is in “ItemQty” which has fields “Name” and “Qty”.

Create a repeating group with just the unique item names
Type of content: text
Data Source: Search for ItemQtys’s Name:unique elements

In the cell, display the text, and also display the sum of the quantities of a search:
Search for ItemQty’s Qty:sum

In the search, have a constraint of:
Name = Current cell’s text

3 Likes

Thanks to you both! I’m glad I asked.

Hello. Great that you did well with calculating the sum of fields in a repeating group (RG). Could you pls tell me how to handle it:

  • which field type I must asign to the fields in RG so that I can make a sum?
  • At the moment I use text elements for such fields to display the number. Do I have to replace that Text elements by Input Elements for this purpose?
    Thanks
1 Like