How do I sum the values in a text inside a repeating group?

Hello! I´d like to sum the numbers in a text field of a repeating group. How can I do that? This is a chat page and I´d like to sum the unread messages of a repeating group.
This sum should be outside the RG.
Thanks!

Sem título5

Is the sum itself being done outside of the repeating group, or within it? I usually do something like this inside of the repeating group itself. then it is just a matter of using :count

It’s outside the RG.

If you move it inside of the RG it will be easier, you can use “this cell”

@ezduriez, maybe I’m misunderstanding you (and in that case ignore my comment) but the easiest way to sum data in a repeating group is to do something like this:

Just be careful, unless a repeating group is set to full list, it might not contain all off the data yet, it will load data when you f.i. scroll down a page. If that is a problem for you, just add a search similair to the one you use for the RG to the field which shows the totals:

Gerbert - MOG Consultancy - No Code Coaching & Consulting

3 Likes

Definetely the sum option doesn´t show up for me in any situation. So I tried this way below:


The issue is: the messages should get data from the perent´s group and I can´t set a list of groups as a data. It allows me to get only one chat as it shows in the red cicled message above.
Any ideas?

This is what I have been doing:
image
image

It is a text inside of the RG itself. It counts just the total of the individual RG cell. Perhaps I am misunderstanding your need.

This is the sum I need. Sometimes I feel very dumb not getting a result using Bubble! Lol

Sem título12

1 Like

@ezduriez, maybe a small example helps:

A list of chats:

  • started by the current user
  • plus a total of messages sent by the current user per chat
  • at the bottom (below the repeating group) a total of messages send by the current user in those chats

  1. Two data types, chats and messages:

  1. Some sample data in both data types / tables:

  1. A repeating group showing all of the chats the current user started:

  1. In order to show the number of messages a user posted in a certain chat, a search is done using the chat in the current cell:

  1. In order to show the total number of messages sent by the current user in the chats in the repeating group, the data in the repeating group can be used in the search:

Note 1: In order to prepare the data fast I added a couple of user fields to the two data types, probably it is better to use the built in field Created By.

Does anyone can take a look on my editor? I couldn´t solve it with all the explanations.
The element I´m trying to fix is “Text Search for Messages” inside the “Group Chat”, inside “g Animate”.
Run the application with user Carlos if you need.

@ezduriez

The value and parent group mentioned in the red square are empty. Since a Created Date will always have a value and you did not set “Ignore empty constraints” nothing will be shown probably.

image

See if adjusting that helps, if not let’s have another look. In order to debug stuff like this just remove contraints until you see data, from that point start adding and adjusting constraints again.

I selected “Ignore empty constraints” and returned 14. It should be 7. I just need do find a way now to insert in “Data source” of “Group Chat” a list os chats that contains current user but this data only allows one chat instead of a list.

Sem título13

I´d like to thanks @gerbertdelangen who gave me a HUGE help with this issue. He helped me inbox and I had to make a slight change in my database. Now everything is working perfectly!

Thank you!

Image1

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.