Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Error for IF function

Vanessa_JWS
8 - Asteroid

Can anyone advise why is my "IF" function not working?

Per the screenshots, the formula is working fine till I input "No" before "ENDIF".

6 REPLIES 6
Luke_C
17 - Castor
17 - Castor

Hi @Vanessa_JWS 

 

Seems to be a data type issue. What data type is the 'check tax rate' field? You could wrap that in a 'ToString()' function, or remove the quotes around 10. 

JamesCharnley
13 - Pulsar

Hi @Vanessa_JWS. Based on the position of the red underline signalling error, my best guess is that your 'Check tax rate' variable is numerical, but you've wrapped the 10 in "" to indicate a string. If you remove that then it might work.

ShankerV
17 - Castor

@Vanessa_JWS 

 

The problem you have encountered is datatype issue. Where the you are doing the comparison String datatype to Int datatype.

 

There are many possible solutions to overcome the datatype issue.

 

Solution 1: Use the SELECT tool, to convert datatype Int to String. And use the same existing formula.

 

ShankerV_0-1670941392962.png

 

 

Solution 2: You don't want to use the condition check 10 within quotes.

String datatype needs quotes. Int doesn't need it.

IF [Column_Name]=10 

THEN "Yes"

ELSE "No"

ENDIF

 

Solution 3: You can rephrase the existing if function as below.

IF tostring([Column_Name])="10"

THEN "Yes"

ELSE "No"

ENDIF

 

Hope this helps!!!! Please ask if you have more questions.

Vanessa_JWS
8 - Asteroid

Thanks! I didn't know the formula would not work if the data type if numeric.. 

Vanessa_JWS
8 - Asteroid

Thanks! This is very helpful. I have resolved this issue!

ShankerV
17 - Castor

@Vanessa_JWS 

 

Welcome, glad that your issue resolved. Happy to help anytime!!!!

Labels