<?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: stats count(eval) always returns zero in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334411#M99388</link>
    <description>&lt;P&gt;also, FTR, if you need to wildcard a value ever (clearly not for this search as you only have 0 and 1), it would be &lt;CODE&gt;count(eval(like(Available,"%0%"))) as "Unavailable"&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jun 2017 14:32:27 GMT</pubDate>
    <dc:creator>cmerriman</dc:creator>
    <dc:date>2017-06-02T14:32:27Z</dc:date>
    <item>
      <title>stats count(eval) always returns zero</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334406#M99383</link>
      <description>&lt;P&gt;I'm having problems with what should be a very simple query.  I'm trying to get a count of events in an "unavailable" state based on ping time values.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Available=if(RTT&amp;gt;20,0,1) | stats count(eval Available==0) as "Unavailable"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have multiple events with RTT values larger than 20 and all of those events have Available set to zero, &lt;CODE&gt;stats&lt;/CODE&gt; always returns 0.&lt;/P&gt;

&lt;P&gt;I've tried a few variations on count(eval), including &lt;CODE&gt;Available=0&lt;/CODE&gt; and &lt;CODE&gt;if(Available=0,1,0)&lt;/CODE&gt;, all with the same result.&lt;/P&gt;

&lt;P&gt;Does anyone see what I've done wrong?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 14:05:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334406#M99383</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-06-02T14:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: stats count(eval) always returns zero</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334407#M99384</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| eval Available=if(RTT&amp;gt;20,0,1) | stats count(eval(Available==0)) as "Unavailable"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you need a parenthesis between the eval and Available.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 14:08:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334407#M99384</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-06-02T14:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: stats count(eval) always returns zero</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334408#M99385</link>
      <description>&lt;P&gt;can you try &lt;BR /&gt;
... | eval Available=if(RTT&amp;gt;20,0,1) | where Available=0 |stats count as "Unavailable"&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 14:10:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334408#M99385</guid>
      <dc:creator>newbie2tech</dc:creator>
      <dc:date>2017-06-02T14:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: stats count(eval) always returns zero</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334409#M99386</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Available=if(RTT&amp;gt;20,0,1) | stats count(eval(Available==0)) AS Unavailable
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or better yet, this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count(eval(RTT&amp;lt;=20)) AS Unavailable
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Jun 2017 14:24:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334409#M99386</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-02T14:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: stats count(eval) always returns zero</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334410#M99387</link>
      <description>&lt;P&gt;Winner!&lt;/P&gt;

&lt;P&gt;FTR, I originally tried &lt;CODE&gt;count(eval (Available==0))&lt;/CODE&gt; which also failed.  Removing the space after &lt;CODE&gt;eval&lt;/CODE&gt; fixed it.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 14:27:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334410#M99387</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-06-02T14:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: stats count(eval) always returns zero</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334411#M99388</link>
      <description>&lt;P&gt;also, FTR, if you need to wildcard a value ever (clearly not for this search as you only have 0 and 1), it would be &lt;CODE&gt;count(eval(like(Available,"%0%"))) as "Unavailable"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 14:32:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-eval-always-returns-zero/m-p/334411#M99388</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-06-02T14:32:27Z</dc:date>
    </item>
  </channel>
</rss>

