Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

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
7 - Meteor

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
20 - Arcturus

[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

binu_acs
21 - Polaris

@pbresney 

 

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

binuacs_0-1643929090495.png

 

 

Qiu
21 - Polaris
21 - Polaris

@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
7 - Meteor

Thank You!

Labels
Top Solution Authors