<?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 How to sum numbers with commas in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37296#M8315</link>
    <description>&lt;P&gt;I would like to calculate the total for the following sample. These are numbers but have comma.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;122 
3,871
17,896
33,011
112,345
1,112,345
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My query looks like this and the values appear in DEL_JOBS&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=_raw  "Total Jobs Deleted: (?&amp;lt;DEL_JOBS&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was trying isnumber("X",Y), but I get this&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;[EventsViewer module] Error in 'eval'&lt;BR /&gt;
command: The 'tonumber' function is&lt;BR /&gt;
unsupported.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;What would be the best way to do this simple arithmetic? &lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Dec 2011 16:39:29 GMT</pubDate>
    <dc:creator>rksubbu</dc:creator>
    <dc:date>2011-12-19T16:39:29Z</dc:date>
    <item>
      <title>How to sum numbers with commas</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37296#M8315</link>
      <description>&lt;P&gt;I would like to calculate the total for the following sample. These are numbers but have comma.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;122 
3,871
17,896
33,011
112,345
1,112,345
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My query looks like this and the values appear in DEL_JOBS&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=_raw  "Total Jobs Deleted: (?&amp;lt;DEL_JOBS&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was trying isnumber("X",Y), but I get this&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;[EventsViewer module] Error in 'eval'&lt;BR /&gt;
command: The 'tonumber' function is&lt;BR /&gt;
unsupported.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;What would be the best way to do this simple arithmetic? &lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2011 16:39:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37296#M8315</guid>
      <dc:creator>rksubbu</dc:creator>
      <dc:date>2011-12-19T16:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum numbers with commas</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37297#M8316</link>
      <description>&lt;P&gt;Maybe not the &lt;STRONG&gt;best&lt;/STRONG&gt; but one that works quickly and easily is to use rex's sed mode to strip off the commas:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=_raw  "Total Jobs Deleted: (?&amp;lt;DEL_JOBS&amp;gt;.*)"
| rex field=DEL_JOBS mode=sed "s/,//g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;I just noticed that the &lt;CODE&gt;convert&lt;/CODE&gt; command has an &lt;CODE&gt;rmcomma&lt;/CODE&gt; operation.   So, this is probably the &lt;STRONG&gt;BEST&lt;/STRONG&gt; way to do it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=_raw  "Total Jobs Deleted: (?&amp;lt;DEL_JOBS&amp;gt;.*)" | convert rmcomma(DEL_JOBS)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Dec 2011 16:58:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37297#M8316</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-12-19T16:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum numbers with commas</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37298#M8317</link>
      <description>&lt;P&gt;why not use replace on every occurrence of a comma then perform your calculations on the new field?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ie. | eval amount=replace(DEL_JOBS, ",", "")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Dec 2011 17:03:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37298#M8317</guid>
      <dc:creator>joshd</dc:creator>
      <dc:date>2011-12-19T17:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum numbers with commas</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37299#M8318</link>
      <description>&lt;P&gt;Thanks for the answer. Worked great!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2011 19:10:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37299#M8318</guid>
      <dc:creator>rksubbu</dc:creator>
      <dc:date>2011-12-19T19:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum numbers with commas</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37300#M8319</link>
      <description>&lt;P&gt;This also worked great. But, I am marking the first answer as accepted because it came in earlier and it was one field less. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Thanks for the answer. Appreciate it.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2011 19:11:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37300#M8319</guid>
      <dc:creator>rksubbu</dc:creator>
      <dc:date>2011-12-19T19:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum numbers with commas</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37301#M8320</link>
      <description>&lt;P&gt;This was the query I used.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=_raw  "Total Jobs Deleted: (?&amp;lt;DEL_JOBS&amp;gt;.*)" | rex field=DEL_JOBS mode=sed "s/,//g" | stats sum(DEL_JOBS) as Total_Jobs_Deleted
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Dec 2011 19:12:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37301#M8320</guid>
      <dc:creator>rksubbu</dc:creator>
      <dc:date>2011-12-19T19:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum numbers with commas</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37302#M8321</link>
      <description>&lt;P&gt;Agree with you totally! I actually read your question wrong initially and thought you had commas where you wanted periods, hence why I immediately recommended the replace command then revised the usage of it, dwaddle beat me to the punch with sed, figured Id leave mine as an option anyhow  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  You also dont have to create a new field you can do: eval DEL_JOBS=replace(DEL_JOBS, ",","")&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:14:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-numbers-with-commas/m-p/37302#M8321</guid>
      <dc:creator>joshd</dc:creator>
      <dc:date>2020-09-28T10:14:23Z</dc:date>
    </item>
  </channel>
</rss>

