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

convert code to actual text

vern
8 - Asteroid

what is the best formula to use to convert codes to actual text; example;  A = Excellent, B = Average, F = Fail, etc.? within Alteryx

19 REPLIES 19
Jean-Balteryx
16 - Nebula
16 - Nebula

Hi @vern ,

 

I built the attached solution that does what you want using either an IF statement or a Switch function.

 

Ask me if you need more details.

 

Cheers,

 

Jean-Baptiste

jdunkerley79
ACE Emeritus
ACE Emeritus

Two options either using a switch statement:

 

Switch([Code],[Code],
       "A","Excellent",
       "B","Average",
       "F","Fail")

 

 

Alternatively, look at using a Find and Replace tool which is a good fit for this

Qiu
21 - Polaris
21 - Polaris

@vern 
Maybe the Find and Replace is suitable for your requirement.

vern
8 - Asteroid
 

i'm very new to Alteryx and these formulas...

the code, code

 

i'm assuming the first code is the field in the table ("A") and the 2nd code is the verbiage ("Excellent"); can the 2nd code be a new field being created or is it replacing the first field? i hope this makes sense.

vern
8 - Asteroid

so, this makes more sense to me than the switch; however, the fields are actually being changed to the new values, correct?

jdunkerley79
ACE Emeritus
ACE Emeritus

The [Code],[Code] in the switch statement says use the Code field's value (first argument) and if no following value matches return [Code] (the second value).

 

Each pair of argument after that is the value to match and the value to use.

Jean-Balteryx
16 - Nebula
16 - Nebula

@vern ,

 

The solution using IF statements I sent you may be more understandable.

 

Cheers,

 

Jean-Baptiste

vern
8 - Asteroid

IF [EEO_CLASS] = "AN"
THEN "American Indian/Alaska Native"
ELSEIF [EEO_CLASS] = "AS"
THEN "Asian"
ELSEIF [EEO_CLASS] = "B"
THEN "Black"
ELSEIF [EEO_CLASS] = "DI"
THEN "Declined to Identify"
ELSEIF [EEO_CLASS] = "DS"
THEN "Declined to Identify"
ELSEIF [EEO_CLASS] = "HI"
THEN "Hispanic or Latino"
ELSEIF [EEO_CLASS] = "NHPI"
THEN "Nat Hawaii/Pacific Islander"
ELSEIF [EEO_CLASS] = "TWO+"
THEN "Two or More Races"
ELSEIF [EEO_CLASS] = "WH"
THEN "White"
ELSE "Ethnicity Unknown"
ENDIF

 

i'm now getting the error "The field "" is not contained in the record. (Expression #2)

Jean-Balteryx
16 - Nebula
16 - Nebula

It's because you didn't select a field or created a new one in the formula tool.

Labels