<?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 return the number of times a specified value appears in a field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-return-the-number-of-times-a-specified-value-appears-in/m-p/224394#M176241</link>
    <description>&lt;P&gt;Stupid double quotes!  Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 11 Nov 2016 09:56:54 GMT</pubDate>
    <dc:creator>andrew_f_trobec</dc:creator>
    <dc:date>2016-11-11T09:56:54Z</dc:date>
    <item>
      <title>How do I return the number of times a specified value appears in a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-return-the-number-of-times-a-specified-value-appears-in/m-p/224391#M176238</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have a simple issue that I can't resolve, and was hoping for support.   I have the following data:&lt;/P&gt;

&lt;P&gt;OBJECT ID,NEW STATE&lt;BR /&gt;
1,STATE ONE&lt;BR /&gt;
1,STATE TWO&lt;BR /&gt;
1,STATE THREE&lt;BR /&gt;
2,STATE ONE&lt;BR /&gt;
2,STATE TWO&lt;BR /&gt;
2,STATE ONE&lt;/P&gt;

&lt;P&gt;My objective is to return the amount of times that "STATE ONE" appears.  I have the following code:&lt;/P&gt;

&lt;P&gt;index = "SAMPLE INDEX" | stats count(eval("NEW STATE" = "STATE ONE")) as "COUNT"&lt;/P&gt;

&lt;P&gt;I was hoping that this would return "COUNT" = 3, but it keeps returning 0.&lt;/P&gt;

&lt;P&gt;What am I missing?&lt;/P&gt;

&lt;P&gt;Any help would be greatly appreciated.  Thank you!&lt;/P&gt;

&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 15:01:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-return-the-number-of-times-a-specified-value-appears-in/m-p/224391#M176238</guid>
      <dc:creator>andrew_f_trobec</dc:creator>
      <dc:date>2016-11-09T15:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I return the number of times a specified value appears in a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-return-the-number-of-times-a-specified-value-appears-in/m-p/224392#M176239</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = "SAMPLE INDEX" "NEW STATE"="STATE ONE" | stats count as "COUNT"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR (field name with spaces should be enclosed in single quotes)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = "SAMPLE INDEX" | stats count(eval('NEW STATE' = "STATE ONE")) as "COUNT"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Nov 2016 15:54:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-return-the-number-of-times-a-specified-value-appears-in/m-p/224392#M176239</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-11-09T15:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I return the number of times a specified value appears in a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-return-the-number-of-times-a-specified-value-appears-in/m-p/224393#M176240</link>
      <description>&lt;P&gt;I hope its not doing a string compare and then returning false of comparing the "NEW STATE" as a string rather than "NEW STATE" as a field with "STATE ONE". Try to extract the fieldname as single worded text like and see if it resolves:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourQuery to return data
| rex "^(?&amp;lt;objectId&amp;gt;[^,]+),(?&amp;lt;newState&amp;gt;).*)$"
| stats count(eval(newState="STATE ONE")) as COUNT
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Nov 2016 15:57:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-return-the-number-of-times-a-specified-value-appears-in/m-p/224393#M176240</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-09T15:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I return the number of times a specified value appears in a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-return-the-number-of-times-a-specified-value-appears-in/m-p/224394#M176241</link>
      <description>&lt;P&gt;Stupid double quotes!  Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 09:56:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-return-the-number-of-times-a-specified-value-appears-in/m-p/224394#M176241</guid>
      <dc:creator>andrew_f_trobec</dc:creator>
      <dc:date>2016-11-11T09:56:54Z</dc:date>
    </item>
  </channel>
</rss>

