Alteryx Designer Desktop Discussions

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

Creating conditional new field via formula tool IF statament

acerdell
8 - Asteroid

Hi,

 

I have 4 fields of product codes that I want to merge them into a single field (WITH A FORMULA TOOL) based on:

 

Please see table below

1st row: if they all contain "same" field names, only display one outcome

2nd row: if only some fields are the same, seperate them with a dash (-)

3rd row: if there is only one entry in any of field 1, 2,3,4 display it on the newfield (or if there are two entries, display all etc)

4th row: if field 1,2,3,4 are all empty, display nothing " "

5th row: If they are all different, display all in "newfield" and seperate them with a dash

 

 

Field1Field2Field3Field4NEWFIELD
ABABABABAB
ABCDABSDAB-CD-SD
 AB  AB
     
ABBCDCFDAB-BC-DC-FD

 

4 REPLIES 4
jgo
Alteryx Alumni (Retired)

Hi @acerdell,

 

See if this workflow contains the solution you're looking for...

 

Best,

 

Jimmy

acerdell
8 - Asteroid

Thanks for the attachment...I actually have a similar workflow that works for my case but I'm particularly looking for a single formula function

 

Like if field1=field2 then...etc

 

Again thanks for the workflow though

jgo
Alteryx Alumni (Retired)

Thank you, @acerdell, for accepting my answer. In terms of a single formula to produce the same output, I don't think there is one without a really complex conditional expression. This approach though would be dynamic in the fact that if there's more fields added, this would still solve for that without modification, as opposed to a formula, it would require you to make some modifications to the expression on those instances.

 

Best,

 

Jimmy

acerdell
8 - Asteroid

That is what I realized too. I had a similar worflow but it looks like that it has some issues, but yours is well built. Thanks again

Labels