<?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 How to return field values from an eval/if statement in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-field-values-from-an-eval-if-statement/m-p/35771#M7864</link>
    <description>&lt;P&gt;I am trying to return change data for our servers. basically I import the list of open changes from the change control system, I then run a search (it will be a macro once it works) that checks if the specified server is currently in a change window,if it is it returns the change number if not it returns "operational"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype=RFClist Change_Status!=Draft OR Change_Status!=Closed Details="*serverA*" earliest=0 latest=now 
| where time() &amp;gt; strptime(Change_Start_Date, "%F %T") AND time() &amp;lt; strptime(Change_End_Date, "%F %T") 
| stats count as window 
| eval window=if(window==0,"Operational",Change_Number)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;when I use a server that is not in a change window I get the "Operational" output, but when I use a server that is in a change window I get nothing. If I just use strings in the eval/if statement I get valid output.&lt;/P&gt;

&lt;P&gt;anyone got any ideas?&lt;/P&gt;</description>
    <pubDate>Thu, 16 May 2013 05:00:29 GMT</pubDate>
    <dc:creator>RickGenesis</dc:creator>
    <dc:date>2013-05-16T05:00:29Z</dc:date>
    <item>
      <title>How to return field values from an eval/if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-field-values-from-an-eval-if-statement/m-p/35771#M7864</link>
      <description>&lt;P&gt;I am trying to return change data for our servers. basically I import the list of open changes from the change control system, I then run a search (it will be a macro once it works) that checks if the specified server is currently in a change window,if it is it returns the change number if not it returns "operational"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype=RFClist Change_Status!=Draft OR Change_Status!=Closed Details="*serverA*" earliest=0 latest=now 
| where time() &amp;gt; strptime(Change_Start_Date, "%F %T") AND time() &amp;lt; strptime(Change_End_Date, "%F %T") 
| stats count as window 
| eval window=if(window==0,"Operational",Change_Number)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;when I use a server that is not in a change window I get the "Operational" output, but when I use a server that is in a change window I get nothing. If I just use strings in the eval/if statement I get valid output.&lt;/P&gt;

&lt;P&gt;anyone got any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 05:00:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-field-values-from-an-eval-if-statement/m-p/35771#M7864</guid>
      <dc:creator>RickGenesis</dc:creator>
      <dc:date>2013-05-16T05:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to return field values from an eval/if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-field-values-from-an-eval-if-statement/m-p/35772#M7865</link>
      <description>&lt;P&gt;The eval/if looks fine. However, I'm thinking that you'd want to use &lt;CODE&gt;_time&lt;/CODE&gt; rather than &lt;CODE&gt;time()&lt;/CODE&gt;  in the &lt;CODE&gt;where&lt;/CODE&gt; statement&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 05:23:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-field-values-from-an-eval-if-statement/m-p/35772#M7865</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-16T05:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to return field values from an eval/if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-field-values-from-an-eval-if-statement/m-p/35773#M7866</link>
      <description>&lt;P&gt;_time is the time of the returned events, I am checking if the returned events (changes) are currently(ie now) active. I believe the search statement is correct as if I replace the change_number field with a string e.g "in change" it works perfectly, except I really wanted the change number as part of the output.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:54:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-field-values-from-an-eval-if-statement/m-p/35773#M7866</guid>
      <dc:creator>RickGenesis</dc:creator>
      <dc:date>2020-09-28T13:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to return field values from an eval/if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-field-values-from-an-eval-if-statement/m-p/35774#M7867</link>
      <description>&lt;P&gt;Oh, then perhaps the Change_Number does not have a value, i.e. is &lt;CODE&gt;null&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 06:54:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-field-values-from-an-eval-if-statement/m-p/35774#M7867</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-16T06:54:28Z</dc:date>
    </item>
  </channel>
</rss>

