<?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: Subgroup rows for addcoltotals in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subgroup-rows-for-addcoltotals/m-p/86299#M22008</link>
    <description>&lt;P&gt;I have answered my own question....the key is to use the appendpipe option. The original query would look something like this:&lt;/P&gt;

&lt;P&gt;index=cats_dogs | stats count(cats) as CATS, count(dogs) as DOGS by CITY, STATE&lt;/P&gt;

&lt;P&gt;when wanting the subgroups in there, the query becomes:&lt;/P&gt;

&lt;P&gt;index=cats_dogs | stats count(cats) as CATS, count(dogs) as DOGS by CITY, STATE | appendpipe [ stats sum(CATS) as CATS, sum(DOGS) as DOGS by STATE ]&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jun 2012 18:40:56 GMT</pubDate>
    <dc:creator>SarahWKarvenz</dc:creator>
    <dc:date>2012-06-28T18:40:56Z</dc:date>
    <item>
      <title>Subgroup rows for addcoltotals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subgroup-rows-for-addcoltotals/m-p/86298#M22007</link>
      <description>&lt;P&gt;I would like to use the add column totals to get the sum of certain rows. Is there a way to specify a "by" clause in the addcoltotals? or a way to choose which rows to add into the data? &lt;/P&gt;

&lt;P&gt;Here is my example data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CITY    STATE   # CATS  # DOGS
CityA   TX  1   5
CityB   TX  2   4
CityC   TX  4   2
CityD   OK  2   2
CityE   OK  5   6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like the output to show me the column totals by State and then also have a total of the entire dataset. The output would give me something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CITY    STATE   # CATS  # DOGS
CityA   TX  1   5
CityB   TX  2   4
CityC   TX  4   2
        TX  7   11
CityD   OK  2   2
CityE   OK  5   6
        OK  7   8
            14  19
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can easily get the last row which has totals for the entire data set by using addcoltotals. But how can I get the totals by state?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2012 16:29:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subgroup-rows-for-addcoltotals/m-p/86298#M22007</guid>
      <dc:creator>SarahWKarvenz</dc:creator>
      <dc:date>2012-06-28T16:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Subgroup rows for addcoltotals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subgroup-rows-for-addcoltotals/m-p/86299#M22008</link>
      <description>&lt;P&gt;I have answered my own question....the key is to use the appendpipe option. The original query would look something like this:&lt;/P&gt;

&lt;P&gt;index=cats_dogs | stats count(cats) as CATS, count(dogs) as DOGS by CITY, STATE&lt;/P&gt;

&lt;P&gt;when wanting the subgroups in there, the query becomes:&lt;/P&gt;

&lt;P&gt;index=cats_dogs | stats count(cats) as CATS, count(dogs) as DOGS by CITY, STATE | appendpipe [ stats sum(CATS) as CATS, sum(DOGS) as DOGS by STATE ]&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2012 18:40:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subgroup-rows-for-addcoltotals/m-p/86299#M22008</guid>
      <dc:creator>SarahWKarvenz</dc:creator>
      <dc:date>2012-06-28T18:40:56Z</dc:date>
    </item>
  </channel>
</rss>

