<?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: Sum of count conditionally within a query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237180#M188606</link>
    <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | eval successcalls=if(result = "declined" OR result = "caller_ended" OR result = "callee_ended",count,null()) | stats sum(count) as NumberofCalls, sum(successcalls) as SuccessfulCalls
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 07 Mar 2016 19:09:25 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-03-07T19:09:25Z</dc:date>
    <item>
      <title>Sum of count conditionally within a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237179#M188605</link>
      <description>&lt;P&gt;I have incoming calls and I'm trying to get total number of calls followed by sum of calls where the field "result" equals declined, caller_ended, or callee_ended. I'm able to get the sum(count) but for  the second part I am only getting a count of the events when really I want to sum the count.&lt;/P&gt;

&lt;P&gt;How can I get a sum of the field count where result is equal to "callee_ended", "caller_ended" or "declined" without filtering the first part of the query&lt;/P&gt;

&lt;P&gt;|stats sum(count) as NumberofCalls , sum(eval(if((result = "declined" OR result = "caller_ended" OR result = "callee_ended"), count, NULL))) AS SuccessfulCalls&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:00:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237179#M188605</guid>
      <dc:creator>dcavag001c</dc:creator>
      <dc:date>2020-09-29T09:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of count conditionally within a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237180#M188606</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | eval successcalls=if(result = "declined" OR result = "caller_ended" OR result = "callee_ended",count,null()) | stats sum(count) as NumberofCalls, sum(successcalls) as SuccessfulCalls
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Mar 2016 19:09:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237180#M188606</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-03-07T19:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of count conditionally within a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237181#M188607</link>
      <description>&lt;P&gt;Thanks for your response but that still only returns the count of events with those parameters rather than a sum(count) with those parameters.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 19:36:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237181#M188607</guid>
      <dc:creator>dcavag001c</dc:creator>
      <dc:date>2016-03-07T19:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of count conditionally within a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237182#M188608</link>
      <description>&lt;P&gt;That should've worked, I've setting the value of successcall to count when your result value follows those condition. Could you post the query that you tried,  possibly full query?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 19:38:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237182#M188608</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-03-07T19:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of count conditionally within a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237183#M188609</link>
      <description>&lt;P&gt;Sorry about that. The query I was using to check the count was incorrect. Your query works! Sorry for the confusion.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 20:10:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-of-count-conditionally-within-a-query/m-p/237183#M188609</guid>
      <dc:creator>dcavag001c</dc:creator>
      <dc:date>2016-03-07T20:10:25Z</dc:date>
    </item>
  </channel>
</rss>

