Calculating a sum with multiple inputs

Hi there,
I’m trying to add up the sum of three fields to display in another field. This all needs to be done upon text entry into the input fields.

In addition the number in the first field needs to display on a total line below it.

I’m running into problems with getting the sum to display. Instead it shows the actual text [[Input1 + Input2 + Input3]] not the sum of the numbers. You can see this on the screenshot.

Help! I’m a newbie.

Without seeing the file we can only guess:

  1. You never defined those variables.
  2. Those variables don’t have the values you think they do.
  3. Any number of other reasons.

My money is on number 1.

Sorry that still doesn’t help. Can you share the file? Check that you have those variables actually defined.

Sure. Give me a minute to send the actual file. I had defined the variables (although maybe incorrectly). In the screencap above though I had removed those and just used the name of the item in the equation. This did not help either.

Sum.rp (109.2 KB)

It looks like you have three variables that are undefined. And that’s why it’s failing. You’re using variables AuthorizedAmountMaster, OutstandingBalance, and NewFunds but those are not defined as local variables or global variables so the expression fails.

It looks like you were trying to use the widget names of the other text fields. You can’t do that. Widget names are not unique so even if you could, it wouldn’t simply work that way. What if you have 20 widgets named OutstandingBalance?

Instead you should use local variables. Open the expression editor (the fx button) and in the bottom half of the window add local variables for each text field widget. Name them whatever you want, and set them to each widget’s text.

Example: LVAR1 = text on widget OutstandingBalance

Then you can use the local variables in your expression.

[[LVAR1 + LVAR2 + LVAR3]]

I suspect this is what the example you referenced did, but when you copied it you did not set the local variables.

Do I set the local variable through the OnTextChange Case 1? I’m not sure how else to access the expression editor.

Yes, in your case. It’s the Set Text action that you want to use to show the sum.

You had a Set Text action that looked like: [[Input1 + Input2 + Inpput3]]. You need to define those variables for the Set Text action to work.

[[Input1 + Input2 + Inpput3]]

And in the expression editor for this action:
Input1 = Text on widget SomeWidget
Input2 = Text on widget SomeOtherWIdget
Input3 = Text on widget AnotherWidget

I am at a loss. I set the variable earlier but now, no matter what I do,

the quotation marks are empty. Here is what I did.

Here is my updated fileSum.rp (109.7 KB)

I also just tried manually entering it into the quotation marks. Still the same - it just shows the equation.

Sum.rp (109.7 KB)

Close, but you’re setting the local variables on an empty Set Variable action and then doing nothing instead of on the Set Text action where you want to use them.

Here’s a working example
Sum-fixed.rp (109.6 KB)

Note that the Set Text action on each text field is exactly the same. I made it once then just copy/pasted the action onto the other two fields.

2 Likes

Ah! I was overthinking it. Thank you so much. This is a lifesaver.