<?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 values if&amp;lt; in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/sum-values-if-lt/m-p/128690#M34947</link>
    <description>&lt;P&gt;Hi Kristian,&lt;/P&gt;

&lt;P&gt;the second option doesn't fit, because i need these filtered events for other stats in this search.&lt;/P&gt;

&lt;P&gt;Thanks a lot for confirming and adding the AND function!&lt;/P&gt;</description>
    <pubDate>Tue, 05 Nov 2013 11:49:59 GMT</pubDate>
    <dc:creator>HeinzWaescher</dc:creator>
    <dc:date>2013-11-05T11:49:59Z</dc:date>
    <item>
      <title>sum values if&lt;</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-values-if-lt/m-p/128688#M34945</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm calculating a duration for each event in the dataset and would like to calculate the sum for all durations &amp;lt; 43200000&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;stats sum(eval(if(Duration_ms&amp;lt;43200000, Duration_ms,0))) AS total_duration&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I made some tests and it the results seem to fit approximately, but I don't feel conifdent whether this is the correct approach. Am I doing it right? Do i need some quotes somewhere in the if-command?&lt;/P&gt;

&lt;P&gt;Is it also possible to have " &amp;gt; AND &amp;lt; " condition here? So to sum all durations &amp;gt;0 AND &amp;lt;43200000.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;Heinz&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:12:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-values-if-lt/m-p/128688#M34945</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2020-09-28T15:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: sum values if&lt;</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-values-if-lt/m-p/128689#M34946</link>
      <description>&lt;P&gt;that works fine&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;stats sum(eval(if((Duration_ms &amp;gt; 0 AND Duration_ms&amp;lt;43200000), Duration_ms,0))) AS Total_Duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or to make it more readable, if it fits your use case, you can make the conditions part of the search terms;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype = blah Duration_ms &amp;gt; 0 Duration_ms &amp;lt; 43200000 | stats sum(Duration_ms) as Total_Duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2013 11:32:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-values-if-lt/m-p/128689#M34946</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-11-05T11:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: sum values if&lt;</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-values-if-lt/m-p/128690#M34947</link>
      <description>&lt;P&gt;Hi Kristian,&lt;/P&gt;

&lt;P&gt;the second option doesn't fit, because i need these filtered events for other stats in this search.&lt;/P&gt;

&lt;P&gt;Thanks a lot for confirming and adding the AND function!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2013 11:49:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-values-if-lt/m-p/128690#M34947</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2013-11-05T11:49:59Z</dc:date>
    </item>
  </channel>
</rss>

