Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Alteryx Formula to count the field

Jaganmohan
8 - Asteroid

Hi Team,

 

In the same column, i  have two different sets of data,

Data as follows , 12 digit Alphanumeric  and few of them 9 characters like mentioned below , i want  to make new column by using formula that if field having 12 characters then RED , If field contain  9  character then Green.

Please help me out in this regards! - Thanks in advance.

 

Input 
Column 
040114AV2 
36209CVG8 
US36224NWQ23 
CA078149DW82 
  
Required Output 
  
040114AV2GREEN
36209CVG8GREEN
US36224NWQ23RED
CA078149DW82RED
11 REPLIES 11
mceleavey
17 - Castor
17 - Castor

@Jaganmohan , as the other have mentioned you did not specify how you wanted the nulls to be handled.

My solution assumed 12 is RED and the rest are GREEN, so it would have made nulls GREEN.

If you want them handled differently you just add another clause, as @atcodedog05 has shown.

 

M.



Bulien

mceleavey
17 - Castor
17 - Castor

@Jaganmohan ,

 

if you have many different possibilities it might be worth maintaining a separate table with the length values:

 

mceleavey_0-1633607125673.png

 

Then using the formula to return the length value:

mceleavey_1-1633607150412.png

 

Then you can simply add new values for new lengths.

mceleavey_2-1633607172267.png

 

mceleavey_3-1633607186566.png

 

Workflow attached.

 

M.

 

 



Bulien

Labels