<?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 create a sum of counts variable in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/351996#M104155</link>
    <description>&lt;P&gt;I have a query that ends with:&lt;/P&gt;

&lt;P&gt;| eval error_message=mvindex(splited,0) | stats count as error_count by error_message  | sort error_count desc  | eval error_rate=round(error_count/(&lt;STRONG&gt;TOTAL_ERRORS&lt;/STRONG&gt;)*100,0)&lt;/P&gt;

&lt;P&gt;Which produces a table with 3 columns:  | error_message | error_count | error_rate |&lt;/P&gt;

&lt;P&gt;error_count represents the number of error_message occurrences for each error_message .&lt;/P&gt;

&lt;P&gt;I'm trying to create a variable named &lt;STRONG&gt;TOTAL_ERRORS&lt;/STRONG&gt; that would represent the total sum of all error_count values (the total number of all error_message occurrences of any type). I need the  &lt;STRONG&gt;TOTAL_ERRORS&lt;/STRONG&gt; variable in order to calculate the error_rate for each error_message.&lt;/P&gt;

&lt;P&gt;I need help in creating this &lt;STRONG&gt;TOTAL_ERRORS&lt;/STRONG&gt; variable.&lt;/P&gt;

&lt;P&gt;I tried to do that with &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;stats sum(error_count)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;which resulted in a table with a single row of the grand total. &lt;/P&gt;

&lt;P&gt;I don't want &lt;STRONG&gt;TOTAL_ERRORS&lt;/STRONG&gt; to have any effect on the table. I need it only for calculations.&lt;/P&gt;

&lt;P&gt;Thank you,&lt;BR /&gt;
Samuel&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 15:14:44 GMT</pubDate>
    <dc:creator>vshakur</dc:creator>
    <dc:date>2020-09-29T15:14:44Z</dc:date>
    <item>
      <title>How to create a sum of counts variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/351996#M104155</link>
      <description>&lt;P&gt;I have a query that ends with:&lt;/P&gt;

&lt;P&gt;| eval error_message=mvindex(splited,0) | stats count as error_count by error_message  | sort error_count desc  | eval error_rate=round(error_count/(&lt;STRONG&gt;TOTAL_ERRORS&lt;/STRONG&gt;)*100,0)&lt;/P&gt;

&lt;P&gt;Which produces a table with 3 columns:  | error_message | error_count | error_rate |&lt;/P&gt;

&lt;P&gt;error_count represents the number of error_message occurrences for each error_message .&lt;/P&gt;

&lt;P&gt;I'm trying to create a variable named &lt;STRONG&gt;TOTAL_ERRORS&lt;/STRONG&gt; that would represent the total sum of all error_count values (the total number of all error_message occurrences of any type). I need the  &lt;STRONG&gt;TOTAL_ERRORS&lt;/STRONG&gt; variable in order to calculate the error_rate for each error_message.&lt;/P&gt;

&lt;P&gt;I need help in creating this &lt;STRONG&gt;TOTAL_ERRORS&lt;/STRONG&gt; variable.&lt;/P&gt;

&lt;P&gt;I tried to do that with &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;stats sum(error_count)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;which resulted in a table with a single row of the grand total. &lt;/P&gt;

&lt;P&gt;I don't want &lt;STRONG&gt;TOTAL_ERRORS&lt;/STRONG&gt; to have any effect on the table. I need it only for calculations.&lt;/P&gt;

&lt;P&gt;Thank you,&lt;BR /&gt;
Samuel&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:14:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/351996#M104155</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2020-09-29T15:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sum of counts variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/351997#M104156</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
add to your search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats stats sum(error_count) AS Total 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and use it for your calculation.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 15:18:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/351997#M104156</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-08-04T15:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sum of counts variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/351998#M104157</link>
      <description>&lt;P&gt;Thank you for your answer, but I'm getting the following error message:&lt;BR /&gt;
&lt;STRONG&gt;Error in 'eventstats' command. The argument 'stats' is invalid&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 15:34:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/351998#M104157</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-08-04T15:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sum of counts variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/351999#M104158</link>
      <description>&lt;P&gt;yeah, delete the word stats.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 15:35:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/351999#M104158</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-04T15:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sum of counts variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/352000#M104159</link>
      <description>&lt;P&gt;Sorry!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats sum(error_count) AS Total 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 15:37:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/352000#M104159</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-08-04T15:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sum of counts variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/352001#M104160</link>
      <description>&lt;P&gt;Thanks guys, it worked, but I got an extra unnecessary "Total" column in my table.&lt;BR /&gt;
Ho do I get the Total without affecting the table.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:01:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/352001#M104160</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-08-04T16:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sum of counts variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/352002#M104161</link>
      <description>&lt;P&gt;Add &lt;BR /&gt;
| fields - Total &lt;BR /&gt;
after the calculation.&lt;BR /&gt;
If this answer solves your need, please accept it.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:52:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-sum-of-counts-variable/m-p/352002#M104161</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-08-04T16:52:16Z</dc:date>
    </item>
  </channel>
</rss>

