Calling all Racers for the Alteryx Grand Prix! It's time to rev your engines and race to the stage at Inspire! Sign up here.

Alteryx Designer Discussions

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

Add characters to field values if missing

ZoeM
8 - Asteroid

hi!

I have a field that I would like to add characters to at the beginning if they are missing. Please see simple example below, the two missing entries should also have "SI-" added to the beginning. 

I would like to complete this using a Formula Tool.

 

Any help rendered truly appreciated. 

 

StateID
MISI-1234
FL5678
CASI-2345
NMSI-7890
OK8520
TXSI-7412
MOSI-6542
ILSI-6548
WISI-9510
5 REPLIES 5
DataNath
17 - Castor

Hey @ZoeM, here's how I'd go about this, leveraging the StartsWith() function:

 

DataNath_0-1664375645302.png

 

The exclamation mark is uses as NOT and so in this expression we're essentially saying: if the ID doesn't begin with SI then add 'SI-' to the ID number. The else tells Alteryx to leave the ID as is if it doesn't satisfy the if condition i.e. does begin with SI.

MilindG
11 - Bolide

MilindG_0-1664375678187.png

See if this fixes your problem.

binuacs
18 - Pollux

@ZoeM One way of doing this

binuacs_0-1664375863552.png

 

Emmanuel_G
13 - Pulsar

@ZoeM 

 

Find in attachement one way of doing that

 

Emmanuel_G_0-1664376015241.png

 

ZoeM
8 - Asteroid

While all solutions provided the same answer, I had to choose one :)

Labels