Is it possible to code a counting function into the formula tool? My goal is to use the conditional if-then statement to increase the value in one field by one if the value in another field in the same row is not Null, but I seem to be getting error messages any time I try putting an operator in the "then" portion of the conditional statement. So, am I messing up the syntax somewhere or do I have to rely on a different tool to get the job done.
Solved! Go to Solution.
Hey @Oren_Soloman,
If you are doing addition in the "Then" part of the if statement make sure your the data type is numeric in nature. Based off of what you are doing it sounds like you need the field to be an INT or Double.
Hi, @Oren_Soloman
Kindly share the formula argument that you're using.
Otherwise, consider nesting argument components in ToNumber().
Cheers!
This was my first formula attempt:
if [Q1 Alerts]!= Null() then [Total Alerts]=[Total Alerts]+1 endif
Everything seems ok up until I try ending the if statement (that's when the color coding stops and the malformed if statement error pops up)
Then I tried taking out the equals sign:
if [Q1 Alerts]!= Null() then [Total Alerts]+1 endif
But got the same problem. I even tried [Total Alerts]+=1, but that caused more issues. Total Alerts is set as an int16 so adding 1 to it shouldn't be an issue. Maybe it is because [Total Alerts] was created earlier in the same formula tool?
That was one of the first things I checked, because the class mentioned that misaligned data types was one of the most common causes of error messages. It's set to Int16, which should be ok to the best of my knowledge. This is the syntax I'm attempting to run:
if [Q1 Alerts]!= Null() then [Total Alerts]=[Total Alerts]+1 endif
I've also tried [Total Alerts]+1, [Total Alerts]+=1, +1, and +=1
And, once I figure this out my next goal is to run the same thing only with strings.
Hello @Oren_Soloman,
You will need to make sure to include an else piece of the if statement. You should be able to do
if [Q1 Alerts]!= Null() then [Total Alerts]+1 else [Total Alerts] endif
See if that works.
I'm a bit embarrassed at how simple that was. Thank you.
User | Count |
---|---|
19 | |
15 | |
15 | |
8 | |
6 |