<?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: How to |addtotals on a |stats list result? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200578#M58160</link>
    <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="Test" |stats count by "Event Category", "Threat Type" |stats list("Threat Type") as "Threat Type" list(count) as Count by "Event Category" | appendpipe [| stats sum(Count) as Count by "Event Category" | eventstats count as noofrows | where noofrows&amp;gt;1| eval "Event Category"='Event Category'."-Total"  ] | appendpipe [| stats sum(Count) as Count count as noofrows | where noofrows&amp;gt;1 | eval "Event Category"="Grand Total" ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 26 Oct 2015 20:04:12 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2015-10-26T20:04:12Z</dc:date>
    <item>
      <title>How to |addtotals on a |stats list result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200576#M58158</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;

&lt;P&gt;I would like to add a row, about a total (sum), for each segment list (see the picture), and if a list has only one value than there is no need to show a total. (only if possible)&lt;/P&gt;

&lt;P&gt;here is what I got:&lt;/P&gt;

&lt;P&gt;index="Test" |stats count by "Event Category", "Threat Type"  |stats list("Threat Type") as "Threat Type" list(count) as Count by "Event Category"&lt;/P&gt;

&lt;P&gt;Using |addtotal doesn't work at all.&lt;/P&gt;

&lt;P&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/762iED59238235B61C2D/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 19:45:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200576#M58158</guid>
      <dc:creator>bruno_eduardo</dc:creator>
      <dc:date>2015-10-26T19:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to |addtotals on a |stats list result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200577#M58159</link>
      <description>&lt;P&gt;You could probably add an addcoltotals at the end of this query but haven't tested. Note the change is in the second stats command where I'm doing a sum of the count field&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="Test" |stats count by "Event Category", "Threat Type" |stats sum(count) as Total list("Threat Type") as "Threat Type" list(count) as Count by "Event Category" | where Total &amp;gt; 1 | sort -Total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to sort the results within each section you would need to do that between the stats commands. For example&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="Test" |stats count by "Event Category", "Threat Type" | sort -count |stats sum(count) as Total list("Threat Type") as "Threat Type" list(count) as Count by "Event Category" | where Total &amp;gt; 1 | sort -Total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Oct 2015 20:01:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200577#M58159</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2015-10-26T20:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to |addtotals on a |stats list result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200578#M58160</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="Test" |stats count by "Event Category", "Threat Type" |stats list("Threat Type") as "Threat Type" list(count) as Count by "Event Category" | appendpipe [| stats sum(Count) as Count by "Event Category" | eventstats count as noofrows | where noofrows&amp;gt;1| eval "Event Category"='Event Category'."-Total"  ] | appendpipe [| stats sum(Count) as Count count as noofrows | where noofrows&amp;gt;1 | eval "Event Category"="Grand Total" ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Oct 2015 20:04:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200578#M58160</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-10-26T20:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to |addtotals on a |stats list result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200579#M58161</link>
      <description>&lt;P&gt;Thanks, Why I can't  vote for more than one answer?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 20:14:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200579#M58161</guid>
      <dc:creator>bruno_eduardo</dc:creator>
      <dc:date>2015-10-26T20:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to |addtotals on a |stats list result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200580#M58162</link>
      <description>&lt;P&gt;Thanks, Why I can't vote for more than one answer?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 20:15:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200580#M58162</guid>
      <dc:creator>bruno_eduardo</dc:creator>
      <dc:date>2015-10-26T20:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to |addtotals on a |stats list result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200581#M58163</link>
      <description>&lt;P&gt;I tested this method and added the addtotals command...it works well enough:&lt;BR /&gt;
&lt;PRE&gt;index="Test" &lt;BR /&gt;
| stats count by "Event Category", "Threat Type" &lt;BR /&gt;
| stats sum(count) as Total list("Threat Type") as "Threat Type" list(count) as Count by "Event Category" &lt;BR /&gt;
| addtotals col=t fieldname=Total label=TOTAL labelfield="Event Category" &lt;BR /&gt;
| table "Event Category" "Threat Type" "Count" "Total"&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 20:51:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-addtotals-on-a-stats-list-result/m-p/200581#M58163</guid>
      <dc:creator>stmyers7941</dc:creator>
      <dc:date>2015-10-26T20:51:55Z</dc:date>
    </item>
  </channel>
</rss>

