I'm using the following formula and my flow runs fine, but when I save it as an app, I get a formula parse error at character 5.
Stock Past Month is a valid header, the first thing I tried was to use the "columns and constants" option to insert it, so I know the issue isn't trailing spaces or an incorrect spelling.
Any thoughts on what this could be?
if ([Stock Past Month] > 0 and [Stock Current Month] > 0) then 0
elseif ([Stock Past Month] = 0 and [Stock Past Month] = 0) then ([Annual Demand]/12)
else ([Annual Demand]/24) endif
Solved! Go to Solution.
Hi @MLane
Are all of the fields you're using numeric? I think your syntax is fine so the culprit is likely trying to evaluate text fields against numeric arguments. If you wrap them in a 'ToNumber()' or use a select tool to update the data type you may have some luck
They're all of type double, size 8
Notably, I've used the same variable in a formula block immediately before it, with no issue.
if (([Stock Current Month] = 0) and ([CPDN Sums] > 0)) Then [CPDN Sums]
else [Stock Current Month] endif
(yes I should probably be putting both of these into one formula block lol)
Yeah that's super strange, I've taken your formula in with some fake data and it works fine... are you able to share the workflow, or sample data and this one formula tool causing the issue?
Can you post your action tool configuration? My hunch is that you are trying to change the value of [Stock Past Month] - and you have your action tool configured to replace it either in this formula - or in a prior tool. When you replace it you think you are replacing the value in it - you are not - you are replacing the name of the field. This is either changing the name of the field prior to your formula - or changing the name of your field inside the formula.
I unfortunately cannot share the entire workflow, but I have posted the configuration for the formula box. Like I said above, I have no problems running it as a flow. I only get errors when I convert it to an alteryx app and try to run it that way.
O.k. - does that field flow from a specific file when run as app vs when run as workflow.
No, selecting the same files was still resulting in an error. Not sure why but adding a select block before it seems to have fixed the error. Thanks for the help!