Alteryx Designer Desktop Discussions

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

Creating a Yes/No column based on other columns

beadyeyesbb
7 - Meteor

Hi 


I am looking for some help on a formula to create a column which says if a booking is with or without children/infants

 

There are two columns, one called children and one called infants,  that shows the total number of children/infants in the booking. 

 

It's something along the lines of this but I can't quite figure it out, any help much appreciated 🙂 

 

If (children) or (infants) >0

THEN "With children"

ELSE "Without children"

END

 

 

 

 

12 REPLIES 12
markcurry
12 - Quasar

Either of the following formulas should work for you...

 

IF [Children] > 0 OR [Infants] > 0 THEN
"With Children"
ELSE
"Without Children"
ENDIF

 

 

Or 

 

IF [Children] + [Infants] > 0 THEN
"With Children"
ELSE
"Without Children"
ENDIF

 

fmvizcaino
17 - Castor
17 - Castor

Hi @beadyeyesbb ,

 

The correct way to use the condition in order to get your expected results is as following.

 

If [children]>0 or [infants] >0

THEN "With children"

ELSE "Without children"

END

 

Best,

Fernando Vizcaino

beadyeyesbb
7 - Meteor

Thank you for response! 

 

It says malformed IF statement. 

markcurry
12 - Quasar

See the attached example with the formula..

fmvizcaino
17 - Castor
17 - Castor

Would you be able to share a printscreen of your error?

kirans666
8 - Asteroid

The below code should help. 

 

IIF (([Children] > 0 OR [Infants] > 0),
"With Children",
"Without Children")

 

beadyeyesbb
7 - Meteor

sure, d1234.PNGoes this help? 

kirans666
8 - Asteroid

I think you missed the IF at the end of the ENDIF 

fmvizcaino
17 - Castor
17 - Castor

Hi @beadyeyesbb ,

 

You need to end your condition with an ENDIF.

 

Also, your column format cannot be boolean in this case, you need to change its format to a string one.

 

Best,

Fernando Vizcaino

Labels