# Smart way to handle multiple operations?

Hello, i have one question that i cant find a smart way to handle this:

I have a RG that hold multiple values (data + numbers).

I’m creating like a table with description, quantity, tax and price.

Example:
Pendrive 16GB | 2 | 21% | 10€

https://puu.sh/Alq8j/48b9a8c06a.png

I managed to do the operation; and actually works but the problem is when i create multiple rows.

So if i want to calculate multiple rows i had to do:
RG list price:item#1 * RG list quantity:item#1 + RG list price:item#2 * RG list quantity:item#2 - PAID (if user paid something before)

https://puu.sh/AlqiX/7dc3abf94f.png

Actually works pretty fine BUT ONLY when there’s the 2 rows. Because as i’m using a - value, if the second row is missing then returns a negative value, which is not correct (and if i create more than 2 rows, those rows are not beign considered:

https://puu.sh/AlqgS/cacff61891.png

But if i complete the both rows; then it works:

https://puu.sh/Alqi6/a0000119d0.png

I cant “create” a way to handle that dynamicall I.E IF there’s 2 rows, then apply this:

I know i can handle this using conditionals i.e:
RG count: 1 = RG list price:item#1 * RG list quantity:item#1
RG count: 2 = RG list price:item#1 * RG list quantity:item#1 + bla bla bla #2
RG count: 3 = RG list price:item#1 * RG list quantity:item#1 + bla bla bla #2 + bla bla bla #3

Just trying to know if there’s a “smart” way to do this.

Thanks!

Thank you for your answer, thats what i did, i created a Total field, which holds the entire operation:

https://puu.sh/AlqQo/7451656bc0.png

If that’s not what you mean, then not, im not understanding what you mean.

PS: Btw i cant get the correct total, if i put the quantity first * price = gets a huge wrong number, and if i put price * quantity = gets a incorrect number.

Give me a minute, I will make an example

1 Like

Thanks, btw i’m facing another issue that i don’t understand.

Im trying to do this scenario:

PRICE * QUANTITY + PRICE * QUANTITY =
I:E: 10 * 2 + 5 * 2 = Should be 30
But actually is throwing me 50.

https://puu.sh/Als0w/9bf9a8f332.png

So i dont understand whats happening.

PS: I pixelated one of the undertotals, because actually is disabled, and might that can confuse someone.

there you go:

here you can see how the total is updated every time an item (product in the example) is added to the order, and how we change the value of the order using a simple operation.

regarding your problem with the sum being 50 instead of 30 is because bubble is making the operations from left to right, so in your case is doing: 10x2=20 → 20+5=25 → 25x2=50

that’s why I recommend to simplify the operation as in this example.

1 Like

to make the sum at the order’s total:

to make the subtraction of amount payed:

Thanks

Can i get link to editor?

And important question: about you said: regarding your problem with the sum being 50 instead of 30 is because bubble is making the operations from left to right, so in your case is doing: 10x2=20 --> 20+5=25 --> 25x2=50

If i want to make an operation like what im trying to do, in the case i dont want to create all this system, how i should build the syntax to get 30 instead of 50?

Thanks.

I’m sorry I made the example on a private app because I didn’t wanted to create a whole new app for the example, but regarding your question what you can do is have a new field in product named “productTotal” which will have the value of its quantity plus the price, and in the text of the total of the order you can use the expresion “current order’s list of products’ productTotal:sum”

I can’t believe i cant do a simple maths operation instead of creating multiples and multiples fields.

Its something so simple.

A * B + C * D = X

Im trying all the possible combinations and anyone is giving the correct result…

Why we can’t add ‘(’ ‘)’ to the maths?

That should solve the problem:

(A * B) + ( C * D) = X

Edit:

Found a way to solve this.
Installing the math.js plugin i could use ( , ) operations (the symbols and the sum sign, had to write it manually but worked:

https://puu.sh/AlAAF/c4c1a08e3d.png

https://puu.sh/AlAE9/dea215a1fb.gif

Sorry I just saw this, is great to know that you discovered the math.js plugin, is very useful actually . the only thing about your current operation is that it will only make the calculation for two Conceptos_Facturas, if you add more of them they will not be taking in account in the operation. But if you are only going to process two items, then is fine

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