Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Need a help in if else formula of Alteryx that is not giving desired output

YashikaVaish
6 - Meteoroid

Hi Everyone,

 

I am new to Alteryx and trying to put a if/else formula in Alteryx to get the desired column.

I want a formula where If my new column "Data source derived" is blank then put value of "column A" otherwise if again my new column "data source derived" is blank then put "column B" if again it is blank then put "column C". 

I am attaching a workflow and input , In the Input "Data Source" column is having desired output for your reference.and also if you will run the attached workflow then you can see the value of "Derived Data Source" column , it is working for first if else only .

Any help is appreciated and Many Thanks in advance!!

5 REPLIES 5
Ladarthure
14 - Magnetar
14 - Magnetar

Hi @YashikaVaish,

 

you can use a IF formula like the one below :

if [Error category] = 'BD' then 'Error'
elseif IsNull([Data Source Derived]) and !isnull([A]) then [A]
elseif IsNull([Data Source Derived]) and !isnull([B]) then [B]
elseif IsNull([Data Source Derived]) and !isnull([C]) then [C]
else [Data Source Derived] endif

 

It tests if the field A isnull and the new column is null, if not takes A, then tries with B then with C

 

The trick is to use elseif to make it easier to read!

 

Hope it helps!

echuong1
Alteryx Alumni (Retired)

I'm a little confused by your example - are you just trying to get the first value out of A, B, C (going left to right) that is not null? 

 

If so, the attached should work. I essentially added a record ID to each, so I'd know where the records came from. I then removed the extra fields that wouldn't be taken into consideration for this match. I transposed the data to get all of the values in one column, and used a filter to remove the nulls. After that, I used a Summarize to grab the first value per record ID (which would be the first value filled in from the original table). I used a Join to bring these values back together with the original dataset.

 

This is dynamic and will handle any number of columns, rather than hardcoding to only account for three (A, B, C).

 

Hope this helps!

echuong1_0-1612796498699.png

 

YashikaVaish
6 - Meteoroid

Hi , Thank you for the solution but This if else is also giving wrong output like the previous one . I tried this way of if else . 

YashikaVaish
6 - Meteoroid

Hi Thank you for sharing the if else workflow , The output is actually correct but I want to add one more condition like if my error category column value is "BD" then put "error" in "Derived Data Source" column. and also I want to check serial wise like if my newly added column value is null then replace it with column A if still it is null then replace it with column B and so on like in "Data Source" column. Can you help me to rectify if condition for the same.

echuong1
Alteryx Alumni (Retired)

I am not sure what you are looking for with the second part. Are you able to explain through example?

 

With regard to changing the derived code to error if the category is BD, you can use a conditional statement. See attached.

 

echuong1_0-1612798903990.png

 

 

Labels