Hi Alteryx Community,
Appreciate some help regarding this simple challenge
Am currently stuck ending off with an ELSE NULL statement as append below
Would like to end off with ELSE "keep field value the same" statement. In order to keep the field value the same if the above 2 ifs statement is not met.
How would you go about ending the conditional statement
IF
Contains([Channel],"AGGREGATOR")
THEN "Aggregators"
ELSE IF
Contains([Channel], "AFFILIATES")
THEN "Partners and Affiliates"
ELSE Null()
ENDIF
Thanks in advance !
Solved! Go to Solution.
Hi @CM100
This may seem counter-intuitive at first, but you will want to put in the same field that you are calculating on because IF statements cannot overwrite themselves. This is because IF statements are applied successively (More on this below). So in your case it will be:
IF
Contains([Channel],"AGGREGATOR")
THEN "Aggregators"
ELSEIF
Contains([Channel], "AFFILIATES")
THEN "Partners and Affiliates"
ELSE [Channel]
ENDIF
We can think of an IF statement as checking if the logic is true (ie. Does the cell in the column "Channel" contain the word 'AGGREGATOR'?) and if the logic is true - then a formula will be applied. Then the next statement (ELSEIF) will be evaluated and applied successively until it reaches the ELSE statement. However, once a formula is applied - that value cannot be overwritten within the same IF statement.
This is the key for your scenario, because by overwriting your specified cells in "Channel" and then asking to overwrite values with "Channel" - this is ignoring the cells you have specified earlier in your formula.
Hope this helps!
It definitely helps !
Thanks for the detailed explanation
Appreciate !