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
atcodedog05
22 - Nova
22 - Nova

Hi @Jaganmohan 

 

You can use formula like below

 

IF Length([Field1])=9 THEN "Green" ELSE "Red" ENDIF

 

Workflow:

atcodedog05_0-1633605485412.png

 

Hope this helps : )

mceleavey
17 - Castor
17 - Castor

Hi @Jaganmohan ,

 

nice and simple. Just use a formula tool as follows:

 

if length([Input])=12 then "RED" else "GREEN" endif

 

Workflow attached,

 

I hope this helps.

 

M.

 

 



Bulien

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Jaganmohan.,

 

This could be achieved with the use of two column rules in a table tool:

 

JonathanSherman_0-1633605548682.png

 

 

I've attached my workflow for you to download if needed!

 

Kind regards,

Jonathan

Jonathan-Sherman
15 - Aurora
15 - Aurora

Looks like I got the wrong end of the stick on this one! I went a little overboard 😂 Nice to show these things are possible I suppose!

atcodedog05
22 - Nova
22 - Nova

@Jonathan-Sherman wrote:

Nice to show these things are possible I suppose!


I wouldn't disagree on that 😅

Jaganmohan
8 - Asteroid

Thanks for the Quick response .. but in the same column i have blanks as well.

atcodedog05
22 - Nova
22 - Nova

Hi @Jaganmohan 

 

Should Blank be tagged as Null() ?

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Jaganmohan,

 

That's because you'll have other lengths other than 9 and 12 in your column, you could add in an ELSE clause to capture and flag all other values?

 

if length([Input])=12 then "RED" elseif Length([input]) = 9 "GREEN" ELSE "OTHER" endif

 

Kind regards,

Jonathan

atcodedog05
22 - Nova
22 - Nova

Hi @Jaganmohan 

 

Are you expecting something like this.

 

Workflow:

atcodedog05_0-1633606167290.png

 

Hope this helps : )

Labels