<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Converting Text String list into Numbers (Float) _ [solved] in Workato Pros Discussion Board</title>
    <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2923#M1356</link>
    <description>&lt;DIV dir="ltr"&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 25 May 2022 02:04:30 GMT</pubDate>
    <dc:creator>christieparker</dc:creator>
    <dc:date>2022-05-25T02:04:30Z</dc:date>
    <item>
      <title>Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2918#M1351</link>
      <description>&lt;P&gt;Hello everyone! I'm sort of new to Workato and need some help! &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;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). &lt;/P&gt;&lt;P&gt;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: &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;[nil, 4750.0, 11570.19, 3000.0]&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;When I try to use the .to_f formula I ge this error: Error calculating input for field 'value': undefined method `to_f' for #&amp;lt;Array:0x00007ff2cee20180&amp;gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;but I can't convert this to float to be able to sum it... Any thoughts? Thank you in advance!!&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Here is my recipe: &lt;A href="https://community.workato.com/links?lid=v6yS7BEJ8pIrC3ngXBeSfQ&amp;amp;token=%2A%7CTOKEN%7C%2A&amp;amp;url=https%3A%2F%2Fapp.workato.com%2Frecipes%2F2507257%3Fst%3D7c5c792d31d65370e446c338841f64b1e070962785b860598c31a32d925f8ed6" target="_blank" rel="noopener noreferrer"&gt;https://app.workato.com/recipes/2507257?st=7c5c792d31d65370e446c338841f64b1e070962785b860598c31a32d925f8ed6&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 00:12:36 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2918#M1351</guid>
      <dc:creator>ivan3</dc:creator>
      <dc:date>2022-05-25T00:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2919#M1352</link>
      <description>&lt;P&gt;When you extract the text value, do a to_f on it to convert it to a float... try that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 00:25:27 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2919#M1352</guid>
      <dc:creator>patrick-steil</dc:creator>
      <dc:date>2022-05-25T00:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2920#M1353</link>
      <description>&lt;P&gt;Hey Patrick, I tried that actually. But I get an error saying : Error calculating input for field 'value': undefined method `to_f' for #&amp;lt;Array:0x00007ff2cee20180&amp;gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 00:50:54 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2920#M1353</guid>
      <dc:creator>ivan3</dc:creator>
      <dc:date>2022-05-25T00:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2921#M1354</link>
      <description>&lt;P&gt;Gotcha, if you are using .pluck(), it returns an array, so you would need to do something like:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;.pluck().last.to_f&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;the "last" function gets the last element in the array... it should be a one element array, so "first" would also work &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 25 May 2022 01:12:29 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2921#M1354</guid>
      <dc:creator>patrick-steil</dc:creator>
      <dc:date>2022-05-25T01:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2922#M1355</link>
      <description>&lt;P&gt;Hi Ivan,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;You can't use .to_f on an array because that is not a method in the array class. You can only use methods on their appropriate classes, so .to_f can only be used on integers (which are objects within your array, but not the array itself). &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;There are a couple of ways to sum the array. The fastest way with Ruby is to do:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;[your array].compact.sum&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Or, in your case:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;[Items].pluck('final_balance')].compact.sum&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;The .compact method removes nil values from the array, which is important because nil values would cause .sum to error out. The .sum method simply sums all of the numbers left in the array -- floats and ints.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;If your array is truly coming out as "[nil, 4750.0, 11570.19, 3000.0]", then this means your ints and floats are not actually strings. If they were strings, it would look like [nil, "4750.0", "11570.19", "3000.0"]. This would require some additional conversion before summing, and you'd likely have to pass the array through a loop.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;If that is the case, the long way might be more applicable. You would need to accumulate the value in your loop, which could be done like this:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Create a number variable called "Total" before your loop (Step 5) and set the starting value to zero. Then, within your loop, add another "Update Variable" action to add "Total" + "Final Balance Due". This will accumulate as it iterates through each item in the loop. &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;You might also have to add an if conditional to prevent adding nil values, as that would result in another error. If the values were strings, this is where would you use .to_f to convert each index of the array to the floats before adding.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 01:27:27 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2922#M1355</guid>
      <dc:creator>gary1</dc:creator>
      <dc:date>2022-05-25T01:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2923#M1356</link>
      <description>&lt;DIV dir="ltr"&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 25 May 2022 02:04:30 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2923#M1356</guid>
      <dc:creator>christieparker</dc:creator>
      <dc:date>2022-05-25T02:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2924#M1357</link>
      <description>&lt;P&gt;hey Christie! &lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 02:41:49 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2924#M1357</guid>
      <dc:creator>ivan3</dc:creator>
      <dc:date>2022-05-25T02:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2925#M1358</link>
      <description>&lt;P&gt;It worked!!!! thank you much for the detailed response. I learned a lot. &lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 02:42:24 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2925#M1358</guid>
      <dc:creator>ivan3</dc:creator>
      <dc:date>2022-05-25T02:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2926#M1359</link>
      <description>&lt;P&gt;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&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 02:43:19 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2926#M1359</guid>
      <dc:creator>ivan3</dc:creator>
      <dc:date>2022-05-25T02:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2927#M1360</link>
      <description>&lt;P&gt;Hi Ivan,&lt;/P&gt;&lt;P&gt;To convert array elements from string to float and sum , you will need something like this:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;test_array=["4.2", "6.7", "2.3"]&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;test_array.map(&amp;amp;:to_f).sum&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 12:07:09 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2927#M1360</guid>
      <dc:creator>andrew-leung</dc:creator>
      <dc:date>2022-05-25T12:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Text String list into Numbers (Float) _ [solved]</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2928#M1361</link>
      <description>&lt;P&gt;Hi Ivan,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I'm quite new to this myself, but I'll try my best to help you out.&lt;/P&gt;&lt;P&gt;I can see that there is a nil present in your Array, so you will have to omit that using a &lt;STRONG&gt;compact&lt;/STRONG&gt; function.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;After that, you can try creating a &lt;STRONG&gt;Repeater Helper&lt;/STRONG&gt; and assign the &lt;STRONG&gt;list size &lt;/STRONG&gt;to it.&lt;/P&gt;&lt;P&gt;Then drag in a Repeater and convert each item to integer as shown in the screenshot below:&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Then you can pluck the key and sum it.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I how that helps.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;STRONG&gt;Kind Regards,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ashwin A.K&lt;/STRONG&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 25 May 2022 14:23:14 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/converting-text-string-list-into-numbers-float-solved/m-p/2928#M1361</guid>
      <dc:creator>ashwin-ashok</dc:creator>
      <dc:date>2022-05-25T14:23:14Z</dc:date>
    </item>
  </channel>
</rss>

