Can anyone please suggest a way to do the following without having to create a new table to update every time I want to sum a list of records from the database by a particular field?
So as an example I have the following table:
I simply want to Sum the points by name so the answer is:
Living with cats, 120
I know I can do a search for the name and sum values if I know what the search is, but the name is added by the user so there is no way of preempting the search parameters other than group by the names and sum the values.
Its such a simple thing to do in SQL and it’s like a nightmare in Bubble, don’t get me wrong I love bubble, but this simple operation, which would be solved with a GroupBy, confounds me and if I keep banging my head on the table I am sure my eyes will fall out!
So is there any way of achieving this? Even adding a JScript to the page to get the results needed?
I can see this has brought a lot of frustration from many bubblers, is there no solution to this, do I have to resort to building yet another table?
Have you tried putting a RG within a RG? I’m only on a mobile phone right now so I can’t try it but I did it for count (rather than sum) here a while back, in response to another forum post.
Edit: To clarify and prevent confusion, the example is relevant aand should help but it doesn’t actually use a RG within a RG (that was for something else, I think).
Hi @louisadekoya@NigelG, unfortunately, the process described doesn’t allow for summing the values.
:count is available as @louisadekoya has described, but there is no option to sum any of the values or any option to reference the points column when you pull back the :unique causes.
I have tried changing the column type for the points from number to text to see if that would allow me to pull back the text then convert to the number but this is not available, you simply can’t reference the points column within this RG.
Unless I am missing something, it appears Bubble doesn’t want you to sum grouped column values.
Any suggestions, corrections would be appreciated!
So what I was missing is that as you both suggested the first ref the RG as text and pull in the :unique Causes, then using another text field did a search for the points :sum which gives you the lot, so total sum value - not what you want.
But if you then on the query add a constraint
cause = current cell’s text
It does just that and gives you a sum of the unique columns!
Finally cracked it! Thank you for your help and thank you on behalf of anyone else having the same issue!
Glad you figured it out. I was just putting together a summing up example for you. I might as well post it here for anyone else with the same issue. Not sure I used the search constraint like you though.
I just checked and yes, I’m using a hidden RG within a RG, so my original comment was accurate. It’s been a while since I first did it. I have struck a line through my erroneous edit above