Create a grand total from a repeating element that reflects two databases

I am creating a shopping list for my wife that is driving crazy with prices from different places.

As you can see, I have one database with the shopping list, and another with the pricing.

When you see the data in the repeating element, everything works beautifully, but when I want to calculate the total amount of the purchase it is impossible.

I tried to create a workflow to generate a new entire database with the prices included, but again I step into the same issue to reaching the price of the specific product I am evaluating in the recurrent workflow.

I need the help of one of the Bubble gurus. I know that this can be easy for most of you, but for me is like figuring out the secrets of the universe.

Any one?

Are you using the table element or a repeating group?

Either way, I can see you are using a search for Pricing, which you don’t want to do in a repeating group since for every cell in the repeating group (ie: for each Product) you will be performing a search which will slow down your performance, but that is another issue.

You can simply find the total by using the Search for Pricing with constraints that the Product (this assumes your pricing data type has a field that is related to a Product) is in the repeating groups list of Products. Then after that expression you add the operators for each items pricing : sum…however, that assumes there are no quantities.

You’d likely be better off creating a data type that is Order or Purchase which would have the Product, the Quantity and the Price. Then everything would be easier.

1 Like

You are the best. I was actually exploring that solution, but from what I found I would be to use recurrent backend workflows to create the new data type using the two database already in bubble. Am I right with my conclusion?

If you already have the two data types with test or live data, then yes, when you create the new data type, you would need to run workflows to establish the relationships, which would likely be best done via a backend workflow that could be done recursively or use the bulk feature in the editor.

But, if you are just looking to establish these relationships you would build out the workflows to create an order.

1 Like