Advent of Code is now back for a limited time only! Complete as many challenges as you can to earn those badges you may have missed in December. Learn more about how to participate here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Creating a formula based on a column existing or not

nbryanrh
5 - Atom

Hi All,

 

I am quite new to this community, having an issue processing a report whose column might differ on every run. For example:

 

Col ACol BCol C
ABCDEFGHI

 

Sometimes all three columns exist, or sometimes only column B exists, etc.

 

I'd like to create a new column with the following logic:

 

IF (col A exists) THEN [col A]

ELSEIF (col B exists) THEN [col B]

ELSEIF (col C exists) THEN [col C]

ELSE null( )

ENDIF

 

For example, if only Col B & Col C exists, the value taken should be from Col B. How would this be possible? Thanks for your help!

4 REPLIES 4
Qiu
21 - Polaris
21 - Polaris

@nbryanrh 
I think we need to "force" all the column to be present even when they are not. 😀

I created another input file which contains only all the columns then do a union/

0419-nbryanrh-01.PNG0419-nbryanrh-02.png

Gandalf_NotGrey
8 - Asteroid

Hello @Qiu I have a similar query.

Your solution works only when either all three are present or all three are not present. 

If Col A and Col B are present and only Col C is not present, then this does not works, since the union will create a new row instead of adding a null field in the same row.

Can you please help me understand on what to do in such a scenario?

I have added a sample workflow for your reference.

Thanks.

 

Qiu
21 - Polaris
21 - Polaris

@Gandalf_NotGrey 
There are 2 minor points you have missed out in your sample flow. Check below snaoshot with comment.

2025-05-27 200702.jpg2025-05-27 200738.jpg

Gandalf_NotGrey
8 - Asteroid

Thanks @Qiu - Keeping the empty row was wrong, removing it made the workflow work. 

Labels
Top Solution Authors