SWITCH - An alternative to IF functions in Alteryx

I found myself in the position where I wanted to convert a list of written numbers (ie. one, two, three...) into a numerical digit (1,2,3...).

For context, the left shows my input and the right shows my desired output:

Unfortunately, Alteryx cannot automatically convert "worded" numbers into their digital versions. So, I initially thought to create one long IF statement that would deal with this:

Although this works, this took a long time to write, and the syntax makes it very clunky and repetitive when it doesn't need to be.

The Alternative - Switch

SWITCH is an alternative conditional function that instead allows you to create conditions for a given value in one field against several potential outcomes (or "cases"). The main differences between SWITCH and IF are:

  • Switch allows one value to be compared against multiple outcomes
  • Switch only compares one given value at a time (only one field can be inputted into the statement) -> if you need to compare multiple fields, use IF

It works by looking at your values and comparing it to the different cases that have been created in order to try and find a match - when it finds the match, it will output the result that you have written for it.

The syntax for switch is

So, for this example, I would instead write:

Which led me to this output:

Perfect - now I can just deselect the word field and I have reached my output.

Author:
Hannah Norfolk
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab