Alteryx Designer Desktop Discussions

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

If then else statement containing a string and a number

pbresney
6 - Meteoroid

I am attempting to write a formula that outputs a number when a certain word is called upon. 

 

I currently have:

IF [PRODUCT NAME] = "Hammer" THEN [LIMIT_QUANTITY_VOD__C] = 5 ELSE Null() ENDIF

 

However, the output keeps putting a 0 in the column rather than a 5. It seems as though this is a very simple fix however I can not crack it as I am new to alteryx.

5 REPLIES 5
apathetichell
18 - Pollux

[LIMIT_QUANTITY_VOD__C]=5 is a boolean statement. 0 means false -  if [LIMIT_QUANTITY_VOD__C]=5 was true - you'd get -1 (aka true).

 

I think you are trying to overwrite the value of a field named [LIMIT_QUANTITY_VOD__C]

 

so you'd just write 5

so for a numeric field called [LIMIT_QUANTITY_VOD__C]

 

IF [PRODUCT NAME] = "Hammer" THEN  5 ELSE Null() ENDIF

binuacs
20 - Arcturus

@pbresney 

 

IF [PRODUCT NAME] = "Hammer" THEN 5 ELSE Null() ENDIF

binuacs_0-1643929090495.png

 

 

Qiu
20 - Arcturus
20 - Arcturus

@pbresney 
The problem is with this  [LIMIT_QUANTITY_VOD__C] = 5

This is a conditional statement, will return 0 as false and 1 as true.

We can fiix it like this.

0203-pbresney.PNG

DavidP
17 - Castor
17 - Castor

Hi @pbresney 

 

The formula tool works slightly differently in Alteryx compared to other coding languages.

 

If you look at the example below, you define the field you want to change or create first on the dropdown. 

 

The formula is then simply:  IF [PRODUCT NAME] = "Hammer" THEN 5 ELSE Null() ENDIF

 

DavidP_0-1643929042598.png

 

pbresney
6 - Meteoroid

Thank You!

Labels