Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Formula-in-database - syntax error - help

hash9
7 - Meteor

Can someone help me fix the error?

 

SQL Expression:

if ('X' <= 14000 and 'X' >= 10000) then "10-14"
elseif ('X' <= 10000 and 'X' >= 8500) then "8.5-10"
elseif ('X' < 14000) then "U/14"
elseif ('X' > 14000) then "O/14"
else "U/8.5"
endif

 

ERROR:

Formula In-DB (35) Error SQLPrepare: [Hortonworks][Hardy] (80) Syntax or semantic analysis error thrown in server while execurint query. Error message from server: Error while compiling statement: FAILED: ParseException line 1:499 mismatched input 'then' expecting ) near ')' in function specification.

 

Thanks!

2 REPLIES 2
Thableaus
17 - Castor
17 - Castor

Try to use case..when...then instead of if..then.

 

Cheers,

ZacharyM
Alteryx Alumni (Retired)

While I am not a hortonworks expert, I dont think that CASE [Col] WHEN [Cond] THEN [Outcome] will work because of the use of >, >=, <, <= operators.

 

I would try removing the final 'if' from the endif, as in SQL operators, an if statement is usually ended by a simple end, not endif.

Labels