<?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 Unable to add numbers because of currency sign and commas present in the field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-add-numbers-because-of-currency-sign-and-commas/m-p/301580#M90806</link>
    <description>&lt;P&gt;I saw some answers already however did not find anything concrete so asking a new question. &lt;/P&gt;

&lt;P&gt;I have a field where values are in USD, like $123,4.00.&lt;/P&gt;

&lt;P&gt;I want to run addcoltotals on the field, and bring back the currency sign and commas once the operation is done.&lt;/P&gt;

&lt;P&gt;I got rid of currency sign and commas using following:&lt;/P&gt;

&lt;P&gt;| replace  "$&lt;EM&gt;" with "&lt;/EM&gt;" in  | replace "&lt;EM&gt;,&lt;/EM&gt;" with ** in &lt;/P&gt;

&lt;P&gt;Not sure if I need to use replace twice, using a comma didnt work for me so using replace command twice.&lt;/P&gt;

&lt;P&gt;Now which would be the best way to get rid of $ and , signs and add the numbers. And then bring back those signs again.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2017 08:46:14 GMT</pubDate>
    <dc:creator>varad_joshi</dc:creator>
    <dc:date>2017-02-16T08:46:14Z</dc:date>
    <item>
      <title>Unable to add numbers because of currency sign and commas present in the field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-add-numbers-because-of-currency-sign-and-commas/m-p/301580#M90806</link>
      <description>&lt;P&gt;I saw some answers already however did not find anything concrete so asking a new question. &lt;/P&gt;

&lt;P&gt;I have a field where values are in USD, like $123,4.00.&lt;/P&gt;

&lt;P&gt;I want to run addcoltotals on the field, and bring back the currency sign and commas once the operation is done.&lt;/P&gt;

&lt;P&gt;I got rid of currency sign and commas using following:&lt;/P&gt;

&lt;P&gt;| replace  "$&lt;EM&gt;" with "&lt;/EM&gt;" in  | replace "&lt;EM&gt;,&lt;/EM&gt;" with ** in &lt;/P&gt;

&lt;P&gt;Not sure if I need to use replace twice, using a comma didnt work for me so using replace command twice.&lt;/P&gt;

&lt;P&gt;Now which would be the best way to get rid of $ and , signs and add the numbers. And then bring back those signs again.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 08:46:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-add-numbers-because-of-currency-sign-and-commas/m-p/301580#M90806</guid>
      <dc:creator>varad_joshi</dc:creator>
      <dc:date>2017-02-16T08:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to add numbers because of currency sign and commas present in the field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-add-numbers-because-of-currency-sign-and-commas/m-p/301581#M90807</link>
      <description>&lt;P&gt;You would need to escape $ with a backslash as shown in example below. If your fields are numeric try to fieldformat for formatting the results for display only (underlying value will not change only display will change.)&lt;/P&gt;

&lt;P&gt;Following is a run anywhere example. I have used cascaded replace to remove $ and Comma.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults 
 | eval Amount1="$12,000.00"
 | eval Amount2="$12,340.00"
 | eval Amount1=replace(replace(Amount1,"\$",""),",","")
 | eval Amount2=replace(replace(Amount2,"\$",""),",","")
 | eval Total = Amount1 + Amount2
 | eval Total= "$".tostring(Total,"commas")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 10:03:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-add-numbers-because-of-currency-sign-and-commas/m-p/301581#M90807</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-02-16T10:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to add numbers because of currency sign and commas present in the field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-add-numbers-because-of-currency-sign-and-commas/m-p/301582#M90808</link>
      <description>&lt;P&gt;I did this to get rid of $ and commas&lt;/P&gt;

&lt;P&gt;| replace  "$&lt;EM&gt;" with "&lt;/EM&gt;" in "My Field" | replace "&lt;EM&gt;,&lt;/EM&gt;" with ** in "My Field"&lt;/P&gt;

&lt;P&gt;And used your last line to add $ and commas again. &lt;/P&gt;

&lt;P&gt;|  eval "My Field" = "$".tostring('My field',"commas")&lt;/P&gt;

&lt;P&gt;Only thing is, many of my values are now blank. &lt;/P&gt;

&lt;P&gt;Only the amounts with total 3 digits are being populated. They won't have commas. &lt;/P&gt;

&lt;P&gt;Any value above $999 i.e $1,000 is not getting populated.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 12:16:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-add-numbers-because-of-currency-sign-and-commas/m-p/301582#M90808</guid>
      <dc:creator>varad_joshi</dc:creator>
      <dc:date>2017-02-16T12:16:33Z</dc:date>
    </item>
  </channel>
</rss>

