Alteryx Designer Desktop Discussions

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

Evaluate a current field based on multiple conditions and output a new column

Zakir
5 - Atom

Hello,

I need a formula that evaluates "current field" based on its 1st *AND 1st two digits below. For example if current field starts with 2 then I want B, if it starts with 51 then C and if it starts with 52 then C. Is there a way to do it using 1 tool or do I have to use multiple tools/actions to address this?

 

Current FieldConditionResult
2122Starts with 2B
2955Starts with 2B
51Starts with 51C
52Starts with 52D
   
3 REPLIES 3
Luke_C
17 - Castor

Hi @Zakir 

 

A formula tool with an IF statement should accomplish this, the below formula would get the logic. Your current field would need to be converted to a string if it isn't already.

 

if left([Current Field],1) = '2' then 'B'
elseif left([Current Field],2) = '51' then 'C'
elseif left([Current Field],2) = '52' then 'D'
else '' endif

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Zakir,

 

I'd probabbly take the approach of a Find and Replace tool. you'd need to convert the values to strings first (but could always be changed back after) to append results from a lookup table. It also saves you from having to write out and look after a long IF formula which looks at a different number of starting characters (in your example the number of starting characters could be one or two) and keeps it more structured in the process:

 

Jonathan-Sherman_0-1616419621882.png

 

 

For example, my lookup table looks like this:

 

Jonathan-Sherman_1-1616419652292.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Kind regards,

Jonathan

 

 

 

Zakir
5 - Atom

@Jonathan-Sherman This worked as expected. I only made one small change to Find replace tool i.e. I changed the find to Beginning of Field.

 

Thank you!

Zak

Labels