Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Converting string numbers to values inside formula (UPC Check Digit)

patsfan
5 - Atom

Well, here is my first question to the community. 

I am new to Alteryx and find the tool awesome.

This archive of questions and solutions have been a great help (thanks to all).    

 

I am in need of a formula to calculate the values of individual digits inside a string of text-formatted numbers.

 

Example;   

I have an 11 digit number with leading zeros so the field is v_string formatted.

I need to add the values of characters 2, 4, 6, 8, and 10 

Example number 01234567891 would return the value 25 (1+3+5+7+9)

 

The above example is just a component of a longer equations that would mimic this Excel formula.

 

=10-MOD(MID($A2,2,1)+MID($A2,4,1)+MID($A2,6,1)+MID($A2,8,1)+MID($A2,10,1)+(MID($A2,1,1)+MID($A2,3,1)+MID($A2,5,1)+MID($A2,7,1)+MID($A2,9,1)+MID($A2,11,1))*3,10)

 

Any guidance or suggestions would be appreciated.

4 REPLIES 4
MichalM
Alteryx Alumni (Retired)

@patsfan 

 

I don't think I follow the logic you're trying to apply here. Could you explain it in a bit more detail?

benakesh
12 - Quasar

With regex tool in tokenize mode string can be split   and then  long  equation can be built on split  items .

Hope this helps .

patsfan
5 - Atom

Thank you for the quick reply and simple solution.

jessecolucci
5 - Atom

I am in need of a solution to calculate the UPC check digit as well. Would be great if someone uploaded a macro for this :).

Labels