<?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: Sum values from a table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314069#M93999</link>
    <description>&lt;P&gt;Anytime! Glad it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Aug 2017 12:58:20 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-08-31T12:58:20Z</dc:date>
    <item>
      <title>Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314056#M93986</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have created a table in splunk and 1 of the fields is numeric('sloc').&lt;BR /&gt;
I would like to sum the values for each 'core'&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3443i38B2C17D7FF03798/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
I was trying to write something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=testeda_p groupID=sloc_data 
| table core sloc_date sloc
| stats sum(sloc) as sumForCore by core
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But there are no results in the new field I created (sumForCore)&lt;BR /&gt;
My result:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3444iD7D0987A259F728A/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I have also tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats sum(tonumber(sloc)) as sumForCore by core
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and nothing&lt;BR /&gt;
what am I doing wrong?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 08:31:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314056#M93986</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-08-31T08:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314057#M93987</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
did you tried&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=testeda_p groupID=sloc_data 
| stats values(sloc_date) AS sloc_date sum(sloc) as sumForCore by core
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;?&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 09:07:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314057#M93987</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-08-31T09:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314058#M93988</link>
      <description>&lt;P&gt;Just tried and still no result in the sumForCore field&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 09:14:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314058#M93988</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-08-31T09:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314059#M93989</link>
      <description>&lt;P&gt;two stupid tests&lt;BR /&gt;
 index=testeda_p groupID=sloc_data &lt;BR /&gt;
 | stats sum(sloc) by core&lt;/P&gt;

&lt;P&gt;index=testeda_p groupID=sloc_data &lt;BR /&gt;
 | stats count by core&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:34:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314059#M93989</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-29T15:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314060#M93990</link>
      <description>&lt;P&gt;the count works just fine but the sum return no value &lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 09:42:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314060#M93990</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-08-31T09:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314061#M93991</link>
      <description>&lt;P&gt;This means that sloc has a text format and you have to convert it in number.&lt;BR /&gt;
try with &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=testeda_p groupID=sloc_data 
| eval sloc=tonumber(sloc)
| stats values(sloc_date) AS sloc_date sum(sloc) as sumForCore by core
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 09:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314061#M93991</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-08-31T09:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314062#M93992</link>
      <description>&lt;P&gt;Still no results in sumForCore&lt;BR /&gt;
count, min, max&lt;BR /&gt;
only avg and sum doesn't&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 10:25:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314062#M93992</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-08-31T10:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314063#M93993</link>
      <description>&lt;P&gt;yes: count min and max don't use numbers, infact if you verify 2 is greater that 15!&lt;BR /&gt;
if you try &lt;CODE&gt;index=_internal kb=* | head 100 | stats sum(kb) AS kb by host&lt;/CODE&gt; you can see that the method is correct.&lt;BR /&gt;
you should verify format of sloc because there's some problem in format, maybe decimals.&lt;BR /&gt;
try using &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=testeda_p groupID=sloc_data 
| convert num(sloc) AS sloc2
| stats values(sloc_date) AS sloc_date sum(sloc2) as sumForCore by core
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 10:39:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314063#M93993</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-08-31T10:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314064#M93994</link>
      <description>&lt;P&gt;the last suggestion does not work either.&lt;BR /&gt;
I will try to figure out the problem with the format&lt;BR /&gt;
thanks&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 10:57:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314064#M93994</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-08-31T10:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314065#M93995</link>
      <description>&lt;P&gt;How are you getting yout sloc? Is it possible there are whitespaces (before and/or after)?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=testeda_p groupID=sloc_data
 | eval sloc=trim(sloc) 
 | stats sum(sloc) as sumForCore by core
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or extract only digits through rex (if you have decimal values your rex will change). Following rex is based on your sample data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=testeda_p groupID=sloc_data
 | rex field=sloc "(?&amp;lt;sloc&amp;gt;\d+)"
 | stats sum(sloc) as sumForCore by core
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 11:08:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314065#M93995</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-31T11:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314066#M93996</link>
      <description>&lt;P&gt;Thank you!&lt;BR /&gt;
The trim function did solve my problem.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 11:38:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314066#M93996</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-08-31T11:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314067#M93997</link>
      <description>&lt;P&gt;do you ever have any null values is sloc?&lt;/P&gt;

&lt;P&gt;try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=testeda_p groupID=sloc_data 
 | table core sloc_date sloc
 |fillnull sloc value=0
 | stats sum(sloc) as sumForCore by core
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if that doesn't work, add &lt;CODE&gt;|eval sloc=tonumber(sloc)&lt;/CODE&gt;  before the &lt;CODE&gt;fillnull&lt;/CODE&gt; command.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 11:40:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314067#M93997</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-08-31T11:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314068#M93998</link>
      <description>&lt;P&gt;cmerriman, it didnt work for me. I think the problem was with the format of the numbers.&lt;BR /&gt;
the trim function solve my problem.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 12:33:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314068#M93998</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-08-31T12:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Sum values from a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314069#M93999</link>
      <description>&lt;P&gt;Anytime! Glad it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 12:58:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-values-from-a-table/m-p/314069#M93999</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-31T12:58:20Z</dc:date>
    </item>
  </channel>
</rss>

