How to sum the numbers in a string column

Solved!
hvalder01
Level 1
How to sum the numbers in a string column

I have a string column ("CylSize") with these values (7.5, 7.5, 5.125, 3.375).

We need to create a new column with the sum of all the values (7.5+7.5+5.125+3.375) = 23.5.

Please advise what is the best recipe to get it done.


Operating system used: Windows

0 Kudos
1 Solution
MiguelangelC
Dataiker

Hi,

The sum of elements in the same cell can be easily achieved by using a Prepare recipe.  Within this recipe, there are various ways in which the desired results can be obtained.

The most straigtforward path would be to take advantage of visual processors. For example, using the following: 'extract numbers', 'formula', and 'remove columns'.

Capture.PNG

Another option to do the operations in one go could be using a 'custom python function':

Capture2.PNG

 

View solution in original post

0 Kudos
2 Replies
MiguelangelC
Dataiker

Hi,

The sum of elements in the same cell can be easily achieved by using a Prepare recipe.  Within this recipe, there are various ways in which the desired results can be obtained.

The most straigtforward path would be to take advantage of visual processors. For example, using the following: 'extract numbers', 'formula', and 'remove columns'.

Capture.PNG

Another option to do the operations in one go could be using a 'custom python function':

Capture2.PNG

 

0 Kudos
hvalder01
Level 1
Author

Miguel,

Thanks for your help!

I tried the 'custom python function,' and it worked great.

 

 

0 Kudos