<?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: Stats sum function in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Stats-sum-function/m-p/100241#M25930</link>
    <description>&lt;P&gt;or just&lt;BR /&gt;
    index=hig sourcetype=MainframeApps | top limit=0 app_id app_name&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 12:06:04 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2020-09-28T12:06:04Z</dc:date>
    <item>
      <title>Stats sum function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-sum-function/m-p/100239#M25928</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=hig `sourcetype="MainframeApps"  |stats sum(count)|top limit=0  app_id app_name | fields + count, total_count,  percent,app_name, app_id | accum count AS total_count | rename total_count AS "Total Count" app_id AS "App Code" app_name AS "Application Name" count AS "Number of Events" percent AS "Percent"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can not figure out why i can not get the sum function to work? any suggestions&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2012 17:45:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-sum-function/m-p/100239#M25928</guid>
      <dc:creator>Michael_Schyma1</dc:creator>
      <dc:date>2012-07-16T17:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: Stats sum function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-sum-function/m-p/100240#M25929</link>
      <description>&lt;P&gt;I think you just want &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;stats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I also think that you misunderstand how the Splunk command pipeline works. At each step of the pipeline, the intermediate results are transformed. After you run stats count in the pipeline, the fields app_name and app_id are no longer available to you, as they are no longer included in the intermediate results.&lt;/P&gt;

&lt;P&gt;Try this search instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=hig sourcetype="MainframeApps" 
| stats count by app_id app_name
| eventstats sum(count) as total_count
| eval percent = round(count*100/total_count,1)
| rename total_count AS "Total Count" app_id AS "App Code" app_name AS "Application Name" count AS "Number of Events" percent AS "Percent"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:05:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-sum-function/m-p/100240#M25929</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2020-09-28T12:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Stats sum function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-sum-function/m-p/100241#M25930</link>
      <description>&lt;P&gt;or just&lt;BR /&gt;
    index=hig sourcetype=MainframeApps | top limit=0 app_id app_name&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-sum-function/m-p/100241#M25930</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2020-09-28T12:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Stats sum function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-sum-function/m-p/100242#M25931</link>
      <description>&lt;P&gt;Nice - I forgot about the limit=0 on the top command.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2012 07:27:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-sum-function/m-p/100242#M25931</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-07-17T07:27:18Z</dc:date>
    </item>
  </channel>
</rss>

