Basic calculation help required

Thanks for your reply. Could you expand on what you mean by “Doing the math in the database”?

The problem is to show the total when you load the data in the first place or to show it changing while you change the amount of each item in the RG?

Or both :sweat_smile:?

It’s to show it changing while you change the amount of each item.

Although I can’t even find a way of doing the calculation…

Really appreciate any help. I’m just mocking up a simple example that I can link to here. Will hopefully be back with it very soon.

Honestly the simplest way I’ve found is to use a plugin and I can suggest the “Repeating Group Tools” by BDK. This lets you send data from an RG cell to a “receiver” outside the RG then you can run your totals

This do not involve interacting with the database, so it’s quicker.

That’s the hack-free way of doing it. I’m experimenting with some native hacky options but nothing to report yet.

Cheers,
Rob.

That sounds excellent. Thank you. I’ll look into both of those - I’m in awe of you creating one yourself.

Thanks again.

1 Like

@joefarrowsmith hey I just created this. Enter numbers in Input 1 and Input 2 and it displays the multiplication right next to it. Is this something you’re looking for? - https://mafiamap.bubbleapps.io/version-test/calculation?debug_mode=true

I guess there’s more to it because of the currency format?

@bestbubbledev He needs to extract the total from a repeating group.

@joefarrowsmith perhaps hold off using the Communicator plugin - I’ll put a demo together this eve to make sure it solves your use case before you sub/purchase.

And why he needs a plugin to do it? It is not easyer to trigger a workflow everytime his input field changes? So everytime his input field changes, Bubble update his database.

And he will only need a “total” field “Searching for” the SUM of the products showned…

I am not seeing much complexicity here

1 Like

Good point :joy: I had mixed up the facts: you can access workflows from within the RG, but you can’t access RG elements from outside the RG (that’s what the plugin solves). My bad - I’ve removed that suggestion.

RE the “seach for” solution, I’m not a fan since he will also need a way of tracking the users’ shopping cart not just the items in it… Also interacting with the DB will slow down the UX a small bit.

@joefarrowsmith I’d recommend BDK’s plugin if you’re going the non-DB route.

Thanks very much. I’m just on a call getting distracted by something else but I think Giorgi is onto something there. That works nicely. I am indeed trying to apply it to a repeating group and I’m mystified as to why I can’t. I feel I’ve missed something fundamental. I’ll be back when I’m off this call but I do appreciate the help here.

This looks like what I’m trying to do. Any chance you can do a screen dump of the design to see how you achieved that? I don’t think the currency format should be causing there to be more to it. Thank you for this…

Folks, I’m going to have to run for today but I do appreciate everyone’s help with this. It’s been driving me nuts! I actually think I need to make a few db design changes to my data.
I’ll be back on tomorrow (I’m UK based) - just didn’t want anyone in a different timezone thinking I’m not interested by not replying straightaway to further input.
Thanks again.

@joefarrowsmith I’m not doing anything special but you got it.

1 Like

@joefarrowsmith

My apologies to all that I have not read the entire thread in detail, but I did scan through it. :grimacing:

Perhaps something along these lines could help a bit. Notwithstanding the current UI, current flows and current dB structure and exact names of the objects … the following aims to be somewhat of a reference:

Order
Title (text)
Total dollar amount (number)
Line items (list of line items)

Product
Name (text)
Price (number)

Line item
Product (product)
Quantity (number)
Order (order)
Dollar amount (number)

  • Create an order
  • Create the line items assigning product and order
  • Add each line item as it is created to the order’s list of line items
  • In the rg of line items (let’s call it rg A) the user inserts the quantity in an input of type number and a flow (trigger when input value changes) calculates the line item amount
  • Below the rg in a group’s of type number populate its data source with an expression “rg A’s list of line items amount :sum” and use this group to load the total amount to the order’s total amount field.

Hope this sparks some ideas :grinning:

1 Like

This is amazing. Thank you so much, I’m in awe of the help here.

I think what I’m going to have to do is edit my database structure which I’d been trying to avoid but, actually, it’s causing me problems. One of my issues is that the input I’m using to take the Qty is simply a “standalone” input, not linked to any DB field. I was hoping I’d be able to have the user “preview” what they’re about to spend and, so long as they’re happy with that, have all the products and quantities taken from those inputs and recorded in the db.

It’s clear to me now that I’d be far better off basing this screen on a live “Order” input which can then perform the calculation because, as it stands, there’s no option to pull my standalone input box into the expression builder but I’ll be able to do it with data type fields.

If it weren’t for the kindness and generosity of you guys on here, I wouldn’t have come this far and while I’m not looking at Grand Totals right this minute, I’m much more confident that I know what to do now to achieve it because all the responses certainly sparked ideas. I also have a good understanding of Custom States, calculations, workflows etc - dropping yourself in it like I did is frustrating to others but the learning curve to get out of it is very valuable and only made possible by you guys. Thank you.

Giorgio,
Many thanks for this. Your generosity with your time and patience to explain this is humbling! I’ve worked out that I need to make some fundamental design changes to my Db to get it to work but your video here has really, really helped me understand calculations etc and my confidence with Bubble has grown. Many, many thanks.
Joe

Definitely some ideas sparked. I’ve marked this as the solution because I now understand that I need to make some fundamental changes and then this response will be the bedrock of my way ahead.
Many thanks.
Have a great weekend

2 Likes

No problem Joe. Best of luck!

FYI