<?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 do I combine subtotals and totals in a search query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391302#M167440</link>
    <description>&lt;P&gt;Yes, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="tutorial" host=www1
| stats sum(bytes) as Bytes by clientip 
| head 10
| addcoltotals Bytes label="SubTotal GBytes" labelfield=clientip
| eval Bytes=round(Bytes/1024/1024,2)
| append
[search index="tutorial" host=www1
| stats sum(bytes) as Bytes by clientip 
| head 10
| addcoltotals Bytes label="SubTotal GBytes" labelfield=clientip
| eval Bytes=round(Bytes/1024/1024,2)]
| addcoltotals Bytes label="Total_GBytes" labelfield=clientip
| eval Bytes=if((clientip=="Total_GBytes"), Bytes/2, Bytes)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Sep 2018 16:10:56 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2018-09-26T16:10:56Z</dc:date>
    <item>
      <title>How do I combine subtotals and totals in a search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391298#M167436</link>
      <description>&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/5829i229C19EE4A43D1B3/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;Is it possible to do this?&lt;/P&gt;

&lt;P&gt;Should I use appendcol? multisearch? join? Please enlightened me.&lt;/P&gt;

&lt;P&gt;Scenario: The IP below the &lt;STRONG&gt;Sub-Total&lt;/STRONG&gt; is the "server" while the others are "clients". &lt;/P&gt;

&lt;P&gt;I used the tutorialdata.zip of Splunk in this case but the IPs indicated are only samples.&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 01:45:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391298#M167436</guid>
      <dc:creator>rajyah</dc:creator>
      <dc:date>2018-09-25T01:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine subtotals and totals in a search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391299#M167437</link>
      <description>&lt;P&gt;Here's one way.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval mydata="1server,12.34.56.78,1.1!!!! 1server,99.99.99.99,1.2!!!! 1server,88.88.88.88,1.3!!!! 1server,11.11.11.22,1.4!!!! 2client,123.232.22.11,50" 
| makemv delim="!!!! " mydata 
| mvexpand mydata
| makemv delim="," mydata 
| eval type=mvindex(mydata,0), IP=mvindex(mydata,1), value=mvindex(mydata,2)
| table type IP value
| rename COMMENT as "The above just enters your sample data." 

| rename COMMENT as "Mark the records as details so we can identify them to process them multiple times." 
| eval rectype="detail"

| rename COMMENT as "Create and mark the desired subtotal records." 
| appendpipe [
    | where rectype="detail" AND type!="2client" 
    | stats sum(value) as value by type 
    | eval IP="subtotal", rectype="subtotal"
    ]

| rename COMMENT as "Create and mark the desired total record." 
| appendpipe [
    | where rectype="detail" 
    | stats sum(value) as value 
    | eval IP="total", rectype="total", type="total"
    ]

| rename COMMENT as "Format the output values, sort records into order, rename fields, drop unneeded fields." 
| eval value=round(1.00*tonumber(value),1)
| sort 0 type rectype IP
| rename IP as ClientIP value as GBytesUsed
| table ClientIP GBytesUsed
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Sep 2018 02:53:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391299#M167437</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-09-25T02:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine subtotals and totals in a search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391300#M167438</link>
      <description>&lt;P&gt;Thanks a lot for replying sir. I really appreciate it. I'm fairly new in Splunk but I think your query only search for a static list of ip. Here is my query:&lt;/P&gt;

&lt;P&gt;index="tutorial" host=www1&lt;BR /&gt;
| stats sum(bytes) as Bytes by clientip &lt;BR /&gt;
| head 10&lt;BR /&gt;
| addcoltotals Bytes label="Total GBytes" labelfield=clientip&lt;BR /&gt;
| eval Bytes=round(Bytes/1024/1024,2)&lt;/P&gt;

&lt;P&gt;I used the tutorialdata.zip of Splunk. The query logically goes until "sub-total" from the given problem. What I wanted to know is if there's a way to add another search result below the given query then add them again to get the "Total".&lt;/P&gt;

&lt;P&gt;Thank you sir.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 05:32:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391300#M167438</guid>
      <dc:creator>rajyah</dc:creator>
      <dc:date>2018-09-25T05:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine subtotals and totals in a search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391301#M167439</link>
      <description>&lt;P&gt;Or should I say, the IP below the 'Sub-Total' will be the top 1 from source=www3 while the other clients will be from source=www1.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 07:06:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391301#M167439</guid>
      <dc:creator>rajyah</dc:creator>
      <dc:date>2018-09-26T07:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine subtotals and totals in a search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391302#M167440</link>
      <description>&lt;P&gt;Yes, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="tutorial" host=www1
| stats sum(bytes) as Bytes by clientip 
| head 10
| addcoltotals Bytes label="SubTotal GBytes" labelfield=clientip
| eval Bytes=round(Bytes/1024/1024,2)
| append
[search index="tutorial" host=www1
| stats sum(bytes) as Bytes by clientip 
| head 10
| addcoltotals Bytes label="SubTotal GBytes" labelfield=clientip
| eval Bytes=round(Bytes/1024/1024,2)]
| addcoltotals Bytes label="Total_GBytes" labelfield=clientip
| eval Bytes=if((clientip=="Total_GBytes"), Bytes/2, Bytes)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Sep 2018 16:10:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391302#M167440</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-09-26T16:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine subtotals and totals in a search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391303#M167441</link>
      <description>&lt;P&gt;Thank you so much sir. You saved my life!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 01:29:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-subtotals-and-totals-in-a-search-query/m-p/391303#M167441</guid>
      <dc:creator>rajyah</dc:creator>
      <dc:date>2018-09-27T01:29:03Z</dc:date>
    </item>
  </channel>
</rss>

