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.
SOLVED

Assign Specific Numeric Values to Distinct V_String Values into a New Column

RifferX
8 - Asteroid

Similar to a CASE statement in SQL, I want to take specific V_String field values (of which there are ten distinct) and assign a number value to each in a newly created column. I have been struggling with this using formulas and can't get it to work. Below are some examples of my data:

 

Column name: Acknowledged_Time

V_String values: A = 0 Days Acknowledge, B = 1 Day Acknowledge, C = 2 Days Acknowledge and D = 3-7 Days Acknowledge etc.

 

I want to create the new column (Acknowledge_Score) and assign values of 10 for A = 0 Days Acknowledge, 9.5 for B..., 9 for C... and 8... for D etc.

 

Currently, I am Grouped By TeamGroup (of which there are nine distinct) and the above mentioned Acknowledged_Time with some other fields that are not an issue.

 

My goal is to eventually create scores for each TeamGroup after first doing some more calculating and blending, but this string issue is holding me up. This is my first question on here (Newb) and am hoping to get some help. Appreciate any feedback.

2 REPLIES 2
JoshKushner
12 - Quasar

You can use a "Switch" statement in the formula tool to achieve your desired result ==> Switch(Value,Default,Case1,Result1,...,CaseN,ResultN)

Reference Material for the Switch Statement: https://help.alteryx.com/9.5/Reference/Functions.htm#Conditional

 

If I understand your example below, the formula would look like:

 

Switch([Acknowledged_Time],Null(),"A=0",10,"B=1",9.5,"C=2",9,...,CaseN,ResultN)

RifferX
8 - Asteroid

Josh -- You are the man! Appreciate your help and the link to more detail on the Switch statement.

 

Great community here!

Labels