Free Trial

Alteryx Designer Desktop Discussions

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

Translate/Convert/Change numeric fields to string values

cpowers
7 - Meteor

Hi All, 

 

I have a file with several fields where I have the numeric code 0 = No and 1 = Yes. I have other field that use 0, 1, and additional numbers where 0, and 1 don't equal yes no. Examples:

 

Field              Code with Meaning

Tax Bracket: 1 = 15% or less, 2 = 16-28%, 3+ over 28%

Investment Exp: 1 = None, 2 = Limited, 3 = Good, 4 = Extensive

Risk Tolerance: 1 = Conservative, 2=Conservative Moderate, 3=Moderate, 4=Moderate/Aggressive, 5=Aggressive

 

Trying to think of the best tool(s) or method to go about translating the number codes into string values.

 

Thanks!                        

2 REPLIES 2
neilgallen
12 - Quasar

Without any more information, the simplest route would be to include a reference table with the fields and code meanings. Joining this back to your original dataset (either with the join or find/replace tool) would then bring in the code meanings. No need to convert them in the data.

 

Alternatively you could use a formula tool and write formulas such as

 

if [tax bracket]=1 then "15% or less" elseif

[tax bracke]=2 then "16-28%" else

 

 

etc.

 

but that's more work for each field and more complicated should those meanings ever change. A reference table is easier.

CharlieS
17 - Castor
17 - Castor

There are a couple ways to achieve this, so I'll give a couple examples. The formula tool is probably the most direct. You'll use an IF statement that looks like this:

 

For the [Tax Bracket] field:

IF [Tax Bracket]==1 THEN "15% or Less"

ELSEIF [Tax Bracket]==2 THEN "16-28%"

ELSE "Over 28%" ENDIF

 

You'll need to either change the field type on this field to a string before you apply these values, or create a new field that's a string. The Find Replace tool will be another common option. I've attached an example workflow below.

 

Labels
Top Solution Authors