We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Overwriting in Formula

sswift13
7 - Meteor

I am writing an IF statement with many "ELSE"s in it. I want to label a column based on criteria from other columns. If it matches x criteria, it is labeled with "name1", however if it matches one of the criteria down the line, it needs to be named "name2" instead. Right now, because I have it as "else", it only looks at things that are not caught by previous labels. I have tried breaking up the IF statements, however, that does not help.

If REGEX_Match([CPSC], '^0110\d+.*\s*') then "Seats - EI"
elseif [CPSC] = "012018" then "Seats - EI"

elseif [CPSC] = "180115" then "Seats - EI"
elseif [Part Type] = "C - Computer Software" then "Software - NEI"
elseif [Part Type] = "M - Bulk material" then "Bulk Materials - NEI"
elseif [Part Type] = "N - Charts/sketches/eng specs/material specs" then "Charts/Specs - NEI"
elseif [Part Type] = "X - Non-part-Ok to view" then "Non-Part - NEI"
elseif contains([part name], "sftw") then "Software - NEI"
elseif [base] = "1040" then "Wheel Weights - NEI"
elseif contains([part name], "License Cost") then "Software - NEI"
elseif regex_match([Prefix], 'P\w{4}.*') then "Software - NEI"
elseif [part type] = "F - Fastener/standard part" then "Fasteners"
elseif contains([Part Name], "TEMPL") then "Templates - NEI"
else "" endif

How can I label this column so that if something is first labeled as "Seats - EI", but then qualifies for "Software - NEI", it is labeled as "Software - NEI"? Thanks.

2 REPLIES 2
jamielaird
14 - Magnetar

Hi @sswift13 ,

 

The formula will apply the condition it matches first. Have you tried moving the "Software - NEI" line condition above the "Seats - EI" condition?

 

Another approach, that would also help simplify the formula, is to create a boolean column for each of the "then" values and then add a new column with a formula to define which value to keep when multiple conditions are met (e.g. IF [Software - NEI] AND [Seats - EI] THEN "Software - NEI" ELSE Null() ENDIF)

Qiu
21 - Polaris
21 - Polaris

@sswift13 
I think I will agree with @jamielaird .

But would be much helpful if you could give a sample input and output, specially the "priority" thing.

Labels
Top Solution Authors