<?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 To create a dynamic report using eval splunk. in Reporting</title>
    <link>https://community.splunk.com/t5/Reporting/To-create-a-dynamic-report-using-eval-splunk/m-p/447511#M9764</link>
    <description>&lt;P&gt;|eval Actual_Start_Time=[search index=index ESP_JOB=$Start_Job$ JOB_STATUS=EXEC|return $_time]&lt;BR /&gt;
how to write if condition to return _time if the serach returns result or hardcode 00:00&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 19:55:24 GMT</pubDate>
    <dc:creator>tvon1990</dc:creator>
    <dc:date>2020-09-29T19:55:24Z</dc:date>
    <item>
      <title>To create a dynamic report using eval splunk.</title>
      <link>https://community.splunk.com/t5/Reporting/To-create-a-dynamic-report-using-eval-splunk/m-p/447511#M9764</link>
      <description>&lt;P&gt;|eval Actual_Start_Time=[search index=index ESP_JOB=$Start_Job$ JOB_STATUS=EXEC|return $_time]&lt;BR /&gt;
how to write if condition to return _time if the serach returns result or hardcode 00:00&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:55:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/To-create-a-dynamic-report-using-eval-splunk/m-p/447511#M9764</guid>
      <dc:creator>tvon1990</dc:creator>
      <dc:date>2020-09-29T19:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: To create a dynamic report using eval splunk.</title>
      <link>https://community.splunk.com/t5/Reporting/To-create-a-dynamic-report-using-eval-splunk/m-p/447512#M9765</link>
      <description>&lt;P&gt;Basically, you just adjust your internal search until you are happy with the results, then put it back into your subsearch.&lt;/P&gt;

&lt;P&gt;For example, your current subsearch, as a search, would be ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=index ESP_JOB=$Start_Job$ JOB_STATUS=EXEC
 |table _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You need to make sure you are getting exactly one record, and then if it has nothing in it, you want to override the value.  There are lots of ways to do this, but here's one &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=index ESP_JOB=$Start_Job$ JOB_STATUS=EXEC
 | head 1
 | stats count as mycount first(_time) as _time 
 | eval _time=if(count=0,0,_time)
 | table _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since splunk defaults to return records most recent first, that will return the &lt;CODE&gt;_time&lt;/CODE&gt; of the most recent matching record, or it will return 0 if there are no matching records.&lt;/P&gt;

&lt;P&gt;Now, we wrap that in your square braces and it should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval Actual_Start_Time=[index=index ESP_JOB=$Start_Job$ JOB_STATUS=EXEC
     | head 1
     | stats count as mycount first(_time) as _time 
     | eval _time=if(count=0,0,_time)
     | return $_time]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jun 2018 19:21:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/To-create-a-dynamic-report-using-eval-splunk/m-p/447512#M9765</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-06-07T19:21:45Z</dc:date>
    </item>
  </channel>
</rss>

