Alteryx Designer Desktop Discussions

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

If statement is not working when I add the last value

Kostas
5 - Atom

Hi all, 

 

I am struggling to find what is the problem in that simple IF statement and I would appreciate to have your help:

 

IF [Warranty expiration]>2 AND [Warranty expiration]<7 THEN "Wave 1"
ELSEIF [Warranty expiration]>6 AND [Warranty expiration]<10
THEN "Wave 2"
ELSE "Wave 3"
ENDIF

 

The statement it seems fine until I am entering the last value "Wave 3" and specifically the last ". 

The Warranty expiration is an Int32 field that has been created by the DateTimeMonth([Warranty expiration]) expression and saves the number of the month.

There are no Nulls is that. 

The "Wave x" is save to a new column as string.

 

Thanks in advance, 

Kostas

 

5 REPLIES 5
fmvizcaino
17 - Castor
17 - Castor

Hi @Kostas ,

 

The formula is working as it should when [Warranty expiration] is an int number, if it is a string, it does exactly what you are relating. Maybe you forgot to update the data type in your formula DateTimeMonth([Warranty expiration])

fmvizcaino_0-1599830792073.png

 

 

Best,

Fernando Vizcaino

estherb47
15 - Aurora
15 - Aurora

Hi @Kostas 

 

I'd first check the data type of the field [Warranty expiration]. Although the formula does result in an Int, the formula tool will save it as text unless you specify the data type should be Int. I make that error all of the time, forgetting to set data types.

 

Is the problem that the formula itself is failing everywhere, or only when the data in Warranty Expiration doesn't fall into the criteria for Wave 1 or Wave 2? Seeing the actual errors can help us troubleshoot what's going on

 

Cheers!

Esther

Kostas
5 - Atom

Thank you both for the fast reply. 

 

It seems that it is a data type issue since the formula is working for you Fernado. I am getting the error that you are getting when it is changing to string: 

 

Kostas_0-1599831596407.png

Is there somewhere else that I need to set the data type for Warranty expiration field? 

 

/Kostas

estherb47
15 - Aurora
15 - Aurora

Hi @Kostas 

 

Try changing the variable in your formula to [Month of expiration], which is the Int field from the formula that determines the month.

 

Cheers!

Esther

Kostas
5 - Atom

Of course, that was the issue.... 

 

Many thanks Esther!

Labels