Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

IF THEN Condition on sample data set

Vikas27
7 - Meteor

Hi All, 

 

Thanks for helping me out on all queries. I'm new to Alteryx and coding so curious and learning new everyday. Pardon me for lame questions. 

 

I've a data of 3000 rows which include tons of books to name it simply let's say A,B,C,D....,X,Y,Z. I want to design a code wherein only for book let's say X and Y i want the Pod to be changed to TRS from existing name mentioned on it. But i don't want Pod to be changed for any other book. It should remain as it is. 

 

Now, based on the guidance from one of fellow community member we designed the code. 

 

IF [Book] = "X" OR [Book] = "Y" THEN "TRS" ELSE Null() ENDIF 

 

Now, with this code its impacting all other books i've in my data and overwriting POD to Null which i don't want. I want other books POD to remain as it is.  

 

Can someone please enlighten me, how can we make it on sample of data from exhaustive data?

 

Thanks a lot !

5 REPLIES 5
MTecovis
6 - Meteoroid

Hey Vikas,

 

maybe this will help:

IF [Book] = "X" OR [Book] = "Y" THEN "TRS" ELSE [ColumnPOD] ENDIF 

 

So basically you chose as ELSE action the column itself, so if the Book is X or Y it's changed to "TRS", else it remains the value from the column

 

BR

Vikas27
7 - Meteor

BR - ColumnPOD is not recognized. It came as Unknown variable. 

MTecovis
6 - Meteoroid

Hey Vikas,

 

I don't know what your columns are called, so for example:

MTecovis_0-1648718704250.png

 

Take this structure and you want to rebuild your formula, then if in Column A there is an X or Y you want Column B to change to "TRS" instead of "POD",

 

then your formula would look like this:

 

IF [Column A] = "X" OR [Column A] = "Y" THEN "TRS" ELSE [Column B] ENDIF 

 

Result is a column which should look like this: 

 

MTecovis_1-1648718894222.png

 

Best regards

 

binuacs
20 - Arcturus

@Vikas27 try with brackets like below 

 

IF ([Book] = "X" OR [Book] = "Y") THEN "TRS" ELSE Null() ENDIF 

Vikas27
7 - Meteor

@MTecovis Thanks a lot ! It really worked i've to tweak as per my condition and need to make small change as while doing Column [Pod] i was getting Unbracket error. 

So final condition is 

 

IF [Book] = "X" OR [Book] = "Y" THEN "TRS" ELSE [Pod] ENDIF

Labels