Start Free Trial

Alteryx Designer Desktop Discussions

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

Expression cannot end with an operator error with IF statement in Action tool

dmpope
8 - Asteroid

Hi there,

 

I'm experiencing a parse error with my expression and I can't figure out where it's stemming from. For context -- this formula is connected to two Drop Down tools, one that allows the user to select the month (listed numerically, not month names)  and one that allows the user to select the reporting period. Month is [#1] and Reporting Period is [#2]. The action tool is connected to an input batch macro.

 

What this formula should be doing is if the month selected is 1 and the reporting is monthly, then it changes the month to 12, if quarterly it changes the month to 9, and if annually it leave it as 1. If the month select is not 1 and is reporting is monthly, it will subtract 1 from the month selected, if quarterly it will subtract 3 months, annually will leave is as is.

 

Here is the formula:

 

IF (ToNumber([#1])=1 AND [#2]="Monthly") THEN 12

ELSEIF (ToNumber([#1])!=1 AND [#2] = “Monthly”) THEN (ToNumber([#1]) – 1)

ELSEIF (ToNumber([#1])=1 AND [#2]="Quarterly") THEN 9

ELSEIF (ToNumber([#1])!=1 AND [#2] = “Quarterly”) THEN (ToNumber([#1]) – 3)

ELSEIF [#2] = “Annually” THEN [#1]

ELSE Null()

ENDIF

 

Can anyone help me pinpoint what is causing this "expression cannot end with an operator" error? I looked at the help page (https://knowledge.alteryx.com/index/s/article/Parse-Error-at-charn-An-expression-cannot-end-with-an-...) and from what I can tell, I don't have have anything that actually ends with an operator. I closed the subtractions with the ToNumber formula in parentheses just in case that was causing it, but that's not fixing the issue.

 

Thanks!

4 REPLIES 4
cjaneczko
13 - Pulsar

I think the problem is here.

 

IF (ToNumber([#1])=1 AND [#2]="Monthly") THEN 12

ELSEIF (ToNumber([#1])!=1 AND [#2] = “Monthly”) THEN (ToNumber([#1]) – 1)

ELSEIF (ToNumber([#1])=1 AND [#2]="Quarterly") THEN 9

ELSEIF (ToNumber([#1])!=1 AND [#2] = “Quarterly”) THEN (ToNumber([#1]) – 3)

ELSEIF [#2] = “Annually” THEN [#1]

ELSE Null()

ENDIF

 

I believe you want it to be THEN tonumber([#1])

dmpope
8 - Asteroid

@cjaneczko unfortunately that didn't work

dmpope
8 - Asteroid

Okay I solved it! The opening quotation marks are apparently different when you copy the formula over from Word 😑

goatley1
8 - Asteroid

This is what I was going to point out.  That return ends up mixing data types.  I would also change the Null() to -0-

Labels
Top Solution Authors