<?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 find the sum of several transactions, including a zero result? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194650#M56118</link>
    <description>&lt;P&gt;I am sorry,my search just a simple description of the problem.In fact,it including transctions and some limited conditions.&lt;BR /&gt;
index=a | stats count as a |appendcols [search index=b | stats count as b] | appendcols [search index=c sourcetype=cc "status=4" OR "status=5" OR "status=6" | stats &lt;EM&gt;sum&lt;/EM&gt; (count) as c | fillnull value=0 ] | eval total=a+b+c&lt;/P&gt;</description>
    <pubDate>Wed, 25 Mar 2015 13:50:24 GMT</pubDate>
    <dc:creator>dovelsh12223621</dc:creator>
    <dc:date>2015-03-25T13:50:24Z</dc:date>
    <item>
      <title>How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194645#M56113</link>
      <description>&lt;P&gt;Now, what troubles most is how to find the sum of several transactions, including a zero result.&lt;/P&gt;

&lt;P&gt;I want to run the following searches:&lt;BR /&gt;
index=a | stats count as a &lt;BR /&gt;
index=b | stats count as b&lt;BR /&gt;
index=c | stats count as c (however, the result is 0)&lt;BR /&gt;
Calculated as the sum of three transaction numbers.&lt;/P&gt;

&lt;P&gt;My final search is like this：&lt;BR /&gt;
A:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=a | stats count as a |appendcols [search index=b | stats count as b] | appendcols [search index=c | stats count as c | fillnull value=0 ] |  eval total=a+b+c
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;B:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=a | stats count as a |appendcols [search index=b | stats count as b] | appendcols [search index=c | stats count as c | eval coalesce(c,0) ] |  eval total=a+b+c
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Unfortunately, the two searches have no results. What way should I try? When C is zero, I want the total to equal the sum of A plus B.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 13:08:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194645#M56113</guid>
      <dc:creator>dovelsh12223621</dc:creator>
      <dc:date>2015-03-25T13:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194646#M56114</link>
      <description>&lt;P&gt;Assuming your appendcols searches really are that simple, why not do...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=a OR index=b OR index = C | stats count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Mar 2015 13:32:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194646#M56114</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-03-25T13:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194647#M56115</link>
      <description>&lt;P&gt;The search &lt;CODE&gt;index=a | stats count as a | appendcols [search index=b | stats count as b] | appendcols [search index=c | stats count as c] | eval total=a+b+c&lt;/CODE&gt; works correctly for me.&lt;/P&gt;

&lt;P&gt;Perhaps something like this would work for you if the total is all you seek?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=a OR index=b OR index=c | stats count as total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Mar 2015 13:35:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194647#M56115</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-03-25T13:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194648#M56116</link>
      <description>&lt;P&gt;AppendCols needs a column to join your data on. Since all three of your columns are different, there is nothing to join on. If you are just trying to get the count of everything you can do the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=a OR index=b OR index=C | stats count as total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you need the results separately first, then you can use append instead of appendcols.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=a | eval label = a | stats count by label |append [search index=b | eval label = b| stats count by label] | append [search index=c | eval label = c| stats count by label | fillnull value=0 ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should result in a table like thus:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;label     count
  a         5
  b         2
  c         6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;

&lt;P&gt;==== EDIT ====&lt;/P&gt;

&lt;P&gt;My second search had a typo. The second "append" was typoed to "appendcols". Now it is correct, and both are appends.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 13:39:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194648#M56116</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2015-03-25T13:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194649#M56117</link>
      <description>&lt;P&gt;I am sorry,my search just a simple description of the problem.In fact,it including transctions and some limited conditions.&lt;BR /&gt;
index=a | stats count as a |appendcols [search index=b | stats count as b] | appendcols [search index=c sourcetype=cc "status=4" OR "status=5" OR "status=6" | stats &lt;STRONG&gt;&lt;EM&gt;sum&lt;/EM&gt;&lt;/STRONG&gt; (count) as c | fillnull value=0 ] | eval total=a+b+c&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 13:49:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194649#M56117</guid>
      <dc:creator>dovelsh12223621</dc:creator>
      <dc:date>2015-03-25T13:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194650#M56118</link>
      <description>&lt;P&gt;I am sorry,my search just a simple description of the problem.In fact,it including transctions and some limited conditions.&lt;BR /&gt;
index=a | stats count as a |appendcols [search index=b | stats count as b] | appendcols [search index=c sourcetype=cc "status=4" OR "status=5" OR "status=6" | stats &lt;EM&gt;sum&lt;/EM&gt; (count) as c | fillnull value=0 ] | eval total=a+b+c&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 13:50:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194650#M56118</guid>
      <dc:creator>dovelsh12223621</dc:creator>
      <dc:date>2015-03-25T13:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194651#M56119</link>
      <description>&lt;P&gt;C'log like this:&lt;BR /&gt;
aaaa       &lt;STRONG&gt;count:100&lt;/STRONG&gt;       bbbb&lt;BR /&gt;
xxxxx      &lt;STRONG&gt;count:200&lt;/STRONG&gt;       zzzzz&lt;BR /&gt;
wwww    &lt;STRONG&gt;count:700&lt;/STRONG&gt;      yyyyy&lt;/P&gt;

&lt;P&gt;What I want to do like this:&lt;BR /&gt;
Calculate the &lt;STRONG&gt;sum&lt;/STRONG&gt; of &lt;STRONG&gt;all counts&lt;/STRONG&gt; about C,When C is zero, is equal to the sum of A plus B.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 13:57:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194651#M56119</guid>
      <dc:creator>dovelsh12223621</dc:creator>
      <dc:date>2015-03-25T13:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194652#M56120</link>
      <description>&lt;P&gt;If this solution doesn't work, we might need some sample data to help.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 14:18:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194652#M56120</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-03-25T14:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194653#M56121</link>
      <description>&lt;P&gt;One thing to add, to get the total after the results table you would want to do:&lt;BR /&gt;
    | stats sum(count) as Total&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 14:25:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194653#M56121</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-03-25T14:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194654#M56122</link>
      <description>&lt;P&gt;My search like this:&lt;BR /&gt;
index=a | stats count as a |appendcols [search index=b | stats count as b] | appendcols [search index=c sourcetype=cc "status=4" OR "status=5" OR "status=6" | stats sum (count) as c | fillnull value=0 ] | eval total=a+b+c&lt;BR /&gt;
but ,it has no result,because c is zero.Why not total=A+B???&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 14:47:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194654#M56122</guid>
      <dc:creator>dovelsh12223621</dc:creator>
      <dc:date>2015-03-25T14:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194655#M56123</link>
      <description>&lt;P&gt;C'log like this: &lt;BR /&gt;
aaaa count:100 bbbb&lt;BR /&gt;
xxxxx count:200 zzzzz&lt;BR /&gt;
wwww count:700 yyyyy&lt;/P&gt;

&lt;P&gt;A &amp;amp; B‘log like this:&lt;BR /&gt;
qqqq &lt;BR /&gt;
sssss&lt;BR /&gt;
pppp&lt;BR /&gt;
This should result in a table like thus:&lt;BR /&gt;
label count&lt;BR /&gt;
a          3&lt;BR /&gt;
b          3&lt;BR /&gt;
c         1000&lt;BR /&gt;
total:1006&lt;BR /&gt;
However,when c is zero, the search have no result.I want to calculate the sum like "6".&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 14:51:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194655#M56123</guid>
      <dc:creator>dovelsh12223621</dc:creator>
      <dc:date>2015-03-25T14:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194656#M56124</link>
      <description>&lt;P&gt;I had a typo in my original solution. Please try the new solution. &lt;/P&gt;

&lt;P&gt;Just mentioning again: try using &lt;CODE&gt;append&lt;/CODE&gt; rather than &lt;CODE&gt;appendcols&lt;/CODE&gt;, and don't rename your count to something else. You can then use the pipe command that @masonmorales suggested to get the total of all three searches.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats sum(count) as Total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 18:06:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194656#M56124</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2015-03-25T18:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the sum of several transactions, including a zero result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194657#M56125</link>
      <description>&lt;P&gt;I am sorry,I try to slove the question with the ways you given.But it still has no result .&lt;BR /&gt;
My search like this:&lt;BR /&gt;
index=bancs | stats count | append [search index=apache | stats  sum(bytes) | fillnull value=0 ] | stats sum(count)&lt;BR /&gt;
In a period of time,the search like: &lt;EM&gt;index=apache | stats sum(bytes)&lt;/EM&gt;,has no result, actually.&lt;BR /&gt;
But the search like:&lt;EM&gt;index=bancs | stats count&lt;/EM&gt; has result return.Finally,&lt;EM&gt;stats sum(count)&lt;/EM&gt; has no result,however.I need the finally result &lt;EM&gt;like index=bancs | stats count&lt;/EM&gt; &lt;BR /&gt;
Please help me,thx.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2015 01:25:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-sum-of-several-transactions-including-a-zero/m-p/194657#M56125</guid>
      <dc:creator>dovelsh12223621</dc:creator>
      <dc:date>2015-03-26T01:25:58Z</dc:date>
    </item>
  </channel>
</rss>

