Conditional IF Statements

I’d like an example of using IF statements with variable that are numeric based, not text based. Basically, I am counting a variable to 4. When that variable get to 4, I want to add 1 to another variable.

It seems like I always have syntax errors regardless of what I use. I’m structuring it as follows
IF(Appvariablename =4, Appvariablename2 + 1, 0)

So you are setting an App variable:
Appvariablename2 = [formula] IF(Appvariablename == 4, Appvariablename2 + 1, Appvariablename2)

Awesome. Thanks for the help.

I have a follow up question related to this…

So I have a paragraph text tied to a counter adding 1 when pressed. That works as designed.

I’m trying to avoid multiple touches by the user adding to the counter by mistake. To resolve this, I’ve made the text disappear on touch so that it can’t be inadvertently touched again. Any thoughts on how to change the value from 1 to 0 so it can no longer add to the counter if touched by mistake.

Ideally, I’d like to use the check box when box is checked value is 1 but when unchecked value is 0. Since it changes based on the event checkbox on change, it adds 1 when I check the box and 1 again when I uncheck the box.

I also worked on using use the toggle switch but had similar issues related to the event checkbox change.

Thanks for any insight.


If you have a true/false variable binded to your checkbox then on the Checkbox onChange event you just do an IF condition for the true/false variable, then set your counter variable = 1 if true, or 0 if false.

1 Like

HI John,

Do you have any insight on how to help me solve this problem?

I could use some help with adding variables.

This should be simple, but I’m struggling with the right approach.
I have four app variables that when selected generate the value of 1.
I now want to simplify this by creating the total value. So I created another app variable that is the sum of the four other app variable.

So for example app variable BallsB1 = (appVars.B1B1+1)+(appVars.B1B2+1)+(appVars.B1B3+1)+(appVars.B1B4+1)

I know the individual values work because I’ve tested all four, but whenever I try and use the BallsB1 variable, I get no value in return. I want this to be dynamic, meaning that when one of the variables are pressed, BallsB1 may be 1 through 4. All app variables are set to an initial value of 0.

I’ve tried page variables, data variables, but I’m sure there is a simple reason why this is not working but I can’t figure it out!

Any help would be appreciated. I’ve got a lot of variables to add so I thought creating a sum variable would be easy, but again I can’t figure out why it won’t sum individual variable items.

Thank you.

I dont know why that wouldnt work. Are they all NUMBER types?

Yes, It’s literally driving me mad!

The only thing I can think of is that each app value is dependant on it being touched prior to returning the value of 1. So I’m not just adding numbers, I’m adding variables that become numbers once touched. Maybe it is returning their starting value and it’s not dynamic and updating once the other variables are changed to 1 through touch.

What do you mean “touched”?

So the value of 1 is generated when an image is touched on the screen. There are four variables that all have the value change to 1 when the images are touched- so on component tap app.variable +1. My goal was to create a variable that changes when any or all of these four images are touched. It could be 1 through 4. I am trying to simplify the math because I have 36 variables to add grouped into 9 buckets so I was hoping to be able to add the 9 variables that contain the 36 individual variables to make it easier on myself.

Chris LeBreck

So I created a new app to add two variable numbers. It works fine but only when I connect it to “on component tap”. It won’t update dynamically when one of the other two variables change. You can change OnComponentTap to update when one of the other variables update but it only updates when that one variable updates not the other variables in the addition string.

So it must not be updating in the background and require some event action to update. I added to the Update the total variable when one of the other variables update and it worked. You just have to repeat this for all your totals that you want to use. I guess it’s better than adding 36 numbers together…

Let me know if you think of anything else that might help.



There is a Receive Event flow function that might be helpful. You can set it to either Page Variable Changed, or App Variable Changed, so you can hook your variables to these “Changed” events and put your update code in there whenever they change.

Thank you. I’ll give it a try.