Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Formula expression to convert numeric to text

pvara
8 - Asteroid

I have built an app and a particular filed has almost always been text. However thru some testing, incoming data had some numeric values. Is there way using the formula tool to say something like.

if data is numeric then string? I tried placing select tool before the formula and is set to V-string, however my whole workflow blows up because this key field has some numeric values.

 

Thank you in advanced.

1 REPLY 1
CharlieS
17 - Castor
17 - Castor

HI @pvara 

 

So first off, digits can be stored as either numeric or string values. In cases like this, I like using the Multi-Field Formula tool. Even if you use it on a single field, the cool feature is that you can apply a function AND change (read: force) the field type in one tool. So select the one or more fields, check the "update field type" options and use a formula like:

 

ToString([_CurrentField_])

 

So it always comes out a string type and value, and can be applied to as many fields as you would like.

 

EDIT:

Now, if you want to remove any digit characters, that's also possible using RegEx. You could update the previous formula with a RegEx_Replace( to look like this:

 

ToString(RegEx_Replace([_CurrentField_],"\d","")

 

Where any digit characters (referenced by "\d") are replaces with nothing (referenced by "").

 

 

 

Labels