Calculation issue in server connect

I’ve hit a brick wall here and I"m not sure what I’m doing wrong? I have a table that will have a price and a quantity. I’m trying to calculate a subtotal so basically Price * quantity plus the previous value calculated from a repeat. I’ve tried everything. adding .toNumber() to all of the fields etc. Any ideas what could be going wrong?

Hey @baub,

Two questions…

  1. I think that varSubtotal should be global in order to manipulate it inside the repeat… (I think so…) Is it global or you have already checked its value and it recognize its previous value?

  2. You have to calculate this on server side? Because I think client side will get easy…
    I’ll check it in an hour that I’ll be at my pc

As @famousmag suggests, use a global name for your set value.

Whenever I use a set value step with a repeat (including where it is initiated before the repeat) I always use both the Name and Global Name fields, just adding _g to the end for the global one.

inside the repeat it will become (DetailPrice * DetailQuantity)+varSubtotal_g

(you can’t pick a global name from the picker so you have to use code view)

1 Like

Yeah I’ve tried global and not global options. I’ll spin again…

Like this?

Take a look at brian’s post here:

(I will avoid answering without testing the result cause I’m not sure…)

1 Like

Here is another way without have to worry about declaring/setting a global name.

subtotal

2 Likes

Excellent! I would just prefear to not push server and calculate it this way on client side…
I just don’t know if that is accepted by Baub depending on what he has in mind

Thanks @Quy that did the trick for me!!!