<?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 command returning no results if field does not exist. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161188#M45600</link>
    <description>&lt;P&gt;Okay, best thing to do in this case: contact the author of the app over the app page at splunkbase. &lt;BR /&gt;
But to test a value you can use the &lt;CODE&gt;isnum()&lt;/CODE&gt; function with &lt;CODE&gt;eval&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;isnum(X)    
This function takes one argument X and returns TRUE if X is a number.   

... | eval n=if(isnum(field),"yes","no")
or
... | where isnum(field)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 16 Jun 2015 02:58:59 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2015-06-16T02:58:59Z</dc:date>
    <item>
      <title>Stats command returning no results if field does not exist.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161180#M45592</link>
      <description>&lt;P&gt;My specific example is regarding an Active Directory index.  This is my basic query;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ad_test" objectClass="*computer*" cn="workstation" | dedup cn | stats count by name lastLogonTimestamp distinguishedName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This returns no results.  However when manually searching in Active Directory; The object is there.  I ran the following to verify the event was in the index;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ad_test" objectClass="*computer*" cn="workstation" | dedup cn
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The event exists in the index.  However, the event does not have a 'lastLogonTiemstamp' because the object was created manually in Active Directory and the workstation itself never authenticated, or logged on to the domain.&lt;/P&gt;

&lt;P&gt;Active Directory aside; The stats command does not return events when a field in the stats query does not exist.  How do I compensate for this?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2014 14:29:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161180#M45592</guid>
      <dc:creator>mcrawford44</dc:creator>
      <dc:date>2014-02-21T14:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command returning no results if field does not exist.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161181#M45593</link>
      <description>&lt;P&gt;Hi mcrawford44,&lt;/P&gt;

&lt;P&gt;you could create dummy values for the field if the field does not exists, something like this should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | eval foo="N/A" | eval lastLogonTimestamp=coalesce(lastLogonTimestamp,foo) | ..
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this will take &lt;CODE&gt;lastLogonTimestamp&lt;/CODE&gt; if it exists or &lt;CODE&gt;foo&lt;/CODE&gt; if &lt;CODE&gt;lastLogonTimestamp&lt;/CODE&gt; does not exist.&lt;/P&gt;

&lt;P&gt;hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2014 14:49:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161181#M45593</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-02-21T14:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command returning no results if field does not exist.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161182#M45594</link>
      <description>&lt;P&gt;Using;&lt;/P&gt;

&lt;P&gt;index="ad_test" objectClass="&lt;EM&gt;computer&lt;/EM&gt;" cn="workstation" | dedup cn | eval name=upper(cn) | eval lastLogonTimestamp=if(isnull(lastLogonTimestamp), "N/A" , lastLogonTimestamp) | stats count by name lastLogonTimestamp distinguishedName&lt;/P&gt;

&lt;P&gt;No results returned unfortunately.  I'll mess with it a bit unless you see something glaringly wrong.  TO clarify, the field is not empty or NULL.  It simply has not been instantiated on the object.  The field literally does not exist.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2014 15:13:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161182#M45594</guid>
      <dc:creator>mcrawford44</dc:creator>
      <dc:date>2014-02-21T15:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command returning no results if field does not exist.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161183#M45595</link>
      <description>&lt;P&gt;Perfect!  This worked.  You may want to update the parent answer as reference for other viewers.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2014 18:41:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161183#M45595</guid>
      <dc:creator>mcrawford44</dc:creator>
      <dc:date>2014-02-21T18:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command returning no results if field does not exist.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161184#M45596</link>
      <description>&lt;P&gt;Answer updated, feel free to accept the answer &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2014 21:42:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161184#M45596</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-02-21T21:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command returning no results if field does not exist.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161185#M45597</link>
      <description>&lt;P&gt;I am stumped by this problem too.  The coalesce method doesn't seem to work for me.  &lt;/P&gt;

&lt;P&gt;I have deleted my index and recreated.  At the most fundamental level, this search &lt;BR /&gt;
index=summarytimingsindex SqlTime &amp;gt; 0&lt;BR /&gt;
Returns results.  SqlTime is a numeric field.  But as soon as I attempt any stats (or chart etc), including by adding them from the pop up on the selected field, I get no results returned.  I am trying to get avg(SqlTime) but nothing I can do seems to work for this.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 02:17:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161185#M45597</guid>
      <dc:creator>anthonyhall</dc:creator>
      <dc:date>2015-06-16T02:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command returning no results if field does not exist.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161186#M45598</link>
      <description>&lt;P&gt;could it be it is a multi value field? Are you sure about the numeric field?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 02:49:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161186#M45598</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-16T02:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command returning no results if field does not exist.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161187#M45599</link>
      <description>&lt;P&gt;It has a # next to its name in the list of selected fields.  How else would I tell?  Sorry, I am very new to Splunk, and trying to run a canned app which comes with no support and just dreadful documentation, so I am trying to work out why nothing works.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 02:52:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161187#M45599</guid>
      <dc:creator>anthonyhall</dc:creator>
      <dc:date>2015-06-16T02:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command returning no results if field does not exist.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161188#M45600</link>
      <description>&lt;P&gt;Okay, best thing to do in this case: contact the author of the app over the app page at splunkbase. &lt;BR /&gt;
But to test a value you can use the &lt;CODE&gt;isnum()&lt;/CODE&gt; function with &lt;CODE&gt;eval&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;isnum(X)    
This function takes one argument X and returns TRUE if X is a number.   

... | eval n=if(isnum(field),"yes","no")
or
... | where isnum(field)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2015 02:58:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161188#M45600</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-16T02:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command returning no results if field does not exist.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161189#M45601</link>
      <description>&lt;P&gt;Hi MuS, thanks for taking the time to help.  The field is definitely a number based on the result of the above.&lt;BR /&gt;&lt;BR /&gt;
The app didn't come from the splunkbase.  It came from an enterprise software vendor, and it explicitly comes with no support from them.  Very unprofessional of them, I know.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 03:05:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command-returning-no-results-if-field-does-not-exist/m-p/161189#M45601</guid>
      <dc:creator>anthonyhall</dc:creator>
      <dc:date>2015-06-16T03:05:31Z</dc:date>
    </item>
  </channel>
</rss>

