cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Converting Text String list into Numbers (Float) _ [solved]

ivan3
Deputy Chef I
Deputy Chef I

Hello everyone! I'm sort of new to Workato and need some help!


I have to collect a list of values called Final Balance Due and then add them up to generate one final number. The problem is that the original datapill is a text string (even thoug it has only a number).

I used a Lists by Workato action to generate the list and I was able to clear its extra text by using the .pluck formula and (in the step 9) I ended up with a array/list that looks like this:


[nil, 4750.0, 11570.19, 3000.0]


When I try to use the .to_f formula I ge this error: Error calculating input for field 'value': undefined method `to_f' for #<Array:0x00007ff2cee20180>


but I can't convert this to float to be able to sum it... Any thoughts? Thank you in advance!! 


Here is my recipe: https://app.workato.com/recipes/2507257?st=7c5c792d31d65370e446c338841f64b1e070962785b860598c31a32d9...

10 REPLIES 10

patrick-steil
Deputy Chef III
Deputy Chef III

When you extract the text value, do a to_f on it to convert it to a float... try that ๐Ÿ™‚

Hey Patrick, I tried that actually. But I get an error saying : Error calculating input for field 'value': undefined method `to_f' for #<Array:0x00007ff2cee20180>

patrick-steil
Deputy Chef III
Deputy Chef III

Gotcha, if you are using .pluck(), it returns an array, so you would need to do something like:


.pluck().last.to_f


the "last" function gets the last element in the array... it should be a one element array, so "first" would also work ๐Ÿ™‚



Thank you patrick! I actually tried it it gave me a similar error. I ened up using Gary's suggestion below for the .compact.sum formula and it worked! thanks again