Alteryx Designer Desktop Discussions

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

Adding individual numbers in a string

Amy_C
7 - Meteor

If I have number 12345, is there a way to make a new field that's 1+2+3+4+5 = 15?

7 REPLIES 7
jdunkerley79
ACE Emeritus
ACE Emeritus

A little round about but:

 

Add a record id

Use a regex tool to split to rows for each digit

Summarise grouping by record id, summing digit

Join back to original and your done

 

Sample attached

MarqueeCrew
20 - Arcturus
20 - Arcturus

@Amy_C,

 

Please consider this also a solution.  I chose to provide an alternative answer to the one that @jdunkerley79 gave you.  Mine is no more correct, it just gets you there with a single formula tool.  I assume that the string that is the source is no longer than 11 digits.  You can extend if needed (or shorten).   The formula works for 12345 as well as 999999999999.

 

ToNumber(substring(ToString([Value]),0,1))+
ToNumber(substring(ToString([Value]),1,1))+
ToNumber(substring(ToString([Value]),2,1))+
ToNumber(substring(ToString([Value]),3,1))+
ToNumber(substring(ToString([Value]),4,1))+
ToNumber(substring(ToString([Value]),5,1))+
ToNumber(substring(ToString([Value]),6,1))+
ToNumber(substring(ToString([Value]),7,1))+
ToNumber(substring(ToString([Value]),8,1))+
ToNumber(substring(ToString([Value]),9,1))+
ToNumber(substring(ToString([Value]),10,1))

This is the way that the naked eye will add the numbers.

 

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Amy_C
7 - Meteor

Both solutions work wonderfully. Thank you!

derekbelyea
12 - Quasar

Not sure why this is happening.  Tried to open the solution by  jdunkerley79 and this message came back:

 

 

More recent version.jpg

 

Alteryx says I am running the latest version.

 

Version.jpg

 

What is the problem?

 

jdunkerley79
ACE Emeritus
ACE Emeritus

Its was written in 11.3

 

I have changed the version back to 10.5 and attached.

KaneG
Alteryx Alumni (Retired)

Hi @derekbelyea,

 

The latest version is 11.3... that's the version that James created his workflow in. Only came out mid-last week.

derekbelyea
12 - Quasar

Thanks for the heads up.  The "Check for Updates" function in 11.06 told me that my copy of Designer was up to date.  Clearly that function is not working correctly.

Labels