Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Formula parse error

MLane
6 - Meteoroid

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

9 REPLIES 9
Luke_C
17 - Castor
17 - Castor

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

MLane
6 - Meteoroid

They're all of type double, size 8

MLane
6 - Meteoroid

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)

Luke_C
17 - Castor
17 - Castor

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?

 

 

Capture.PNG

 

apathetichell
19 - Altair

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.

 

MLane
6 - Meteoroid

I'm not sure what you mean, the only action blocks I have in this flow are for updating the input and output files.

 

If what you meant is the configuration of the formula tool, I've attached a picture.

 

Thanks for all the help, this is intensely frustrating

MLane
6 - Meteoroid

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.

apathetichell
19 - Altair

O.k. - does that field flow from a specific file when run as app vs when run as workflow. 

MLane
6 - Meteoroid

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!

Labels
Top Solution Authors