Hi, I am brand new to Bubble and Databases in general.
I have been trying to figure this out for a few days now and can’t quite crack it.
I am working on a simple budget calc part of my app and what I need it to do is search a database for keywords (in one field) and then add all of the values for that keyword (in another field) and display the sum of that.
The setup:
I have a database with 2 fields, one called Type (text list) and one Amount (number list).
A user is able to add Types and Amount for example Rent - $800, Utilities - $50 etc.
What I need to do is search the database for all the Types with the same name for example Rent and then add those Amounts (values) together and display it. So if a user adds Rent more than once for example Rent $800 and at a later stage Rent $150 then the app should display Rent - $950.
I know how to do searches for pre-defined keywords and then display those values but in this case the users adds the keywords and I am not sure how to dynamically pull the Type that the user enters and then match them up and display the sum.
Do these Types and Amounts get added to the User data type i.e is it a field on the User? Set the data type of the repeating group to text. Then make the data source of the hidden group Current User’s (whatever the field with the types and amounts is called):each item’s Types:unique elements. That will get out each of the unique Types and assign it to the cell.
Then you can display the name of the Type which would just be the current cell’s text and then the amount which you can retrieve with the Current User’s (list of types and amounts whatever that field is called) where Type = Current cell’s text and then add :sum.
Let me know if this works.
Hey Foraanyas,
Thank you for this, however I am still facing some issues with the second part.
I have a very simple database setup where a user can add an Expense amount and Type and the date gets automatically allocated.

I have set the repeating group to ‘Text’ and got the expense-types to display correctly. But it is when I want to display the amount where I loose the plot a bit.
When I enter ‘current cell’s text’ (as suggested) it doesn’t give me an option for types or amounts
Do I have to ‘do a search for’ and then then choose the ‘expenses’ type? from there I can choose ‘:each item’s Expense-type’ but from here I am lost again.
Thank you so much for the help so far, sorry I am very new to all of this and slowly trying to wrap my head around how to go about things.
Don’t worry about it! Why is your Expense-Type a list of texts? Does the first item in the Expense-Type list link to the first item in the Expense-Amount list?
The next steps depends on the answer to the above question. Just in general can you explain to me how the things are saved. We are able to retrieve the unique Expense-Types so conceptually you need to cycle through the expenses and find the ones where the Expense-Type is equal to the Current Cell’s text and then retrieve the amount of each of those Expenses and then add them up. That would look like this:
Do a Search for Expenses: filtered (Expense-Type = Current Cell’s text):each item’s Expense-Amount:sum. Its a little more complicated than just that though because Expense-Type is a list of texts.