Alteryx Designer Desktop Discussions

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

Convert Number String to Int

BC1414
5 - Atom

Hi All,

 

I am just beginning Alteryx and had the following question. I am hoping to convert a string of a number (i.e. ten) to an integer (i.e. 10). Is there an easy way to do this? 

 

Thanks in advance! 

 

Before:

Ten

 

After:

10

11 REPLIES 11
gautiergodard
13 - Pulsar

Hello @BC1414 

You could change the data type by using a select tool and changing the data type from a string to an int. 

Alternatively, if you want to perform some calculations with this string you could also wrap the string in tonumber() using a formula tool which will allow you to utilize the string as number,

 

Hope this helps!

Felipe_Ribeir0
16 - Nebula

Hi @BC1414 

 

As far as i know, with just Alteryx you will not be able to transform written numbers to numbers.

 

But python has this cool library called word2number (https://pypi.org/project/word2number/) that do exactly that.

Felipe_Ribeir0_0-1666658822194.png

 

Run Alteryx as Admin (to be able to install the library) and run the attached workflow.

 

 

DenisZ
11 - Bolide

If you have a predefined list of words you want to convert now and in the future, you could also alternatively use the "Find and replace tool". However, I would agree with the answer above that Python script would be more suitable.  

 

DenisZ_1-1666674985617.png

 

 

KrishnaChithrathil
11 - Bolide

@Felipe_Ribeir0 

Glad I looked into this solution. I just downloaded word2number library. But how can I use this library on Alteryx? Should I place this library on a specific folder?

 

Thanks,

Krishna

Felipe_Ribeir0
16 - Nebula

Hi  @KrishnaChithrathil 

 

1) Close Alteryx and open it again as Admin

 

Felipe_Ribeir0_0-1666760950676.png

 

2)Download the attached workflow, click on python, the bellow block of code and on Run. This will install the library for Alteryx.

 

Felipe_Ribeir0_1-1666761057300.png

 

 

KrishnaChithrathil
11 - Bolide

@Felipe_Ribeir0 

Thanks much.!

May I ask you, should we always run as Administrator while using python tool or python library? Is that the way it works???

Felipe_Ribeir0
16 - Nebula

@KrishnaChithrathil 

 

No, you just need to do that to have the sufficient role to install the library inside Alteryx folder. After that, you can run it normally.

KrishnaChithrathil
11 - Bolide

Thank you so much @Felipe_Ribeir0 ðŸ˜Š

Felipe_Ribeir0
16 - Nebula

No problem @KrishnaChithrathil ! If you feel that your problem was addressed, please mark the answer as a solution :). Thanks!

Labels
Top Solution Authors