<?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 to get my eval statement to output a certain value, even if there is no result for a certain field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203144#M59011</link>
    <description>&lt;P&gt;sorry if I'm kind of confused.&lt;/P&gt;

&lt;P&gt;What I wanted to do is for them to appear on the table even if there's no data.&lt;/P&gt;

&lt;P&gt;The idea is like on this questions:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/176466/how-to-use-eval-if-there-is-no-result-from-the-bas-1.html"&gt;https://answers.splunk.com/answers/176466/how-to-use-eval-if-there-is-no-result-from-the-bas-1.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/50379/table-message-when-no-results-found.html"&gt;https://answers.splunk.com/answers/50379/table-message-when-no-results-found.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Dec 2016 15:09:42 GMT</pubDate>
    <dc:creator>lloydknight</dc:creator>
    <dc:date>2016-12-20T15:09:42Z</dc:date>
    <item>
      <title>How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203137#M59004</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Here's my search string:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex host=server1 source=mysource
| multikv
| search Process=process1 OR Process=process2
| eval status=if(Runtime!="00:00:00","Running","Not Running") 
| stats latest(status) AS Status, latest(Runtime) AS Runtime by Process
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My question is, what if &lt;CODE&gt;Process=process1&lt;/CODE&gt; and &lt;CODE&gt;Process=process2&lt;/CODE&gt; returns no result?&lt;BR /&gt;
I want them to display the &lt;CODE&gt;"Not Running"&lt;/CODE&gt; status, even if there's no result on the Process field.&lt;BR /&gt;
Searched some answers, but it's not exactly what I am looking for as the dummy field on the answers depends on the &lt;CODE&gt;| stats count&lt;/CODE&gt;, or maybe I just cannot figure it out.&lt;/P&gt;

&lt;P&gt;Can you please guide me in figuring this out?&lt;/P&gt;

&lt;P&gt;Thank you kindly.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 14:18:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203137#M59004</guid>
      <dc:creator>lloydknight</dc:creator>
      <dc:date>2016-12-20T14:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203138#M59005</link>
      <description>&lt;P&gt;EDITED -- try this one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=myindex host=server1 source=mysource
| multikv
| search Process=process1 OR Process=process2
| eval process1=if(searchmatch("process1"),1,0) 
| eval process2=if(searchmatch("process2"),1,0) 
| eventstats count as myCount sum(process1) AS process1 sum(process2) as process2 by Process 
| eval process1=if(myCount=="0",0,process1) 
| eval process2=if(myCount=="0",0,process2) 
| eval status=if((process1&amp;gt;0 OR process2&amp;gt;0) AND Runtime!="00:00:00","Running","Not Running") 
| stats latest(status) AS Status, latest(Runtime) AS Runtime by Process
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=myindex host=server1 source=mysource
 | multikv
 | search Process=process1 OR Process=process2
 | eval status=if(Runtime!="00:00:00","Running","Not Running") 
 | stats latest(status) AS Status, latest(Runtime) AS Runtime by Process
| appendpipe [ stats count | eval "Status"="Not Running"  | where count==0 |table "Status"]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Dec 2016 14:24:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203138#M59005</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2016-12-20T14:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203139#M59006</link>
      <description>&lt;P&gt;could you please provide some sample data?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 14:27:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203139#M59006</guid>
      <dc:creator>PPape</dc:creator>
      <dc:date>2016-12-20T14:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203140#M59007</link>
      <description>&lt;P&gt;hello PPape, the data that I am using comes from the scripts on the Splunk App (Splunk Add-on for Unix and Linux).&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 14:36:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203140#M59007</guid>
      <dc:creator>lloydknight</dc:creator>
      <dc:date>2016-12-20T14:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203141#M59008</link>
      <description>&lt;P&gt;Hello cmmerriman and thank you for your input.&lt;/P&gt;

&lt;P&gt;What if Process=process1 has result and Process=process2 has no result? Will process2 appear on the table?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 14:40:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203141#M59008</guid>
      <dc:creator>lloydknight</dc:creator>
      <dc:date>2016-12-20T14:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203142#M59009</link>
      <description>&lt;P&gt;Yes, it would&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 14:43:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203142#M59009</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-12-20T14:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203143#M59010</link>
      <description>&lt;P&gt;if Process=process1, process2 is null and RunTime!="00:00:00", you should see something like Status = Running, Runtime=xxxx and Process=process1. if there is no data for one of the processes, it shouldn't appear on the table.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 14:45:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203143#M59010</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2016-12-20T14:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203144#M59011</link>
      <description>&lt;P&gt;sorry if I'm kind of confused.&lt;/P&gt;

&lt;P&gt;What I wanted to do is for them to appear on the table even if there's no data.&lt;/P&gt;

&lt;P&gt;The idea is like on this questions:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/176466/how-to-use-eval-if-there-is-no-result-from-the-bas-1.html"&gt;https://answers.splunk.com/answers/176466/how-to-use-eval-if-there-is-no-result-from-the-bas-1.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/50379/table-message-when-no-results-found.html"&gt;https://answers.splunk.com/answers/50379/table-message-when-no-results-found.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 15:09:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203144#M59011</guid>
      <dc:creator>lloydknight</dc:creator>
      <dc:date>2016-12-20T15:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203145#M59012</link>
      <description>&lt;P&gt;tried removing the Process=process1 at the base search and it didn't appear as "Not Running" on the Status, it disappeared &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 16:30:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203145#M59012</guid>
      <dc:creator>lloydknight</dc:creator>
      <dc:date>2016-12-20T16:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203146#M59013</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval Process="process1##process2" | table Process | eval Status="Not Running" 
| makemv Process delim="##" | mvexpand Process
| append [ search index=myindex host=server1 source=mysource
 | multikv
 | search Process=process1 OR Process=process2
 | eval status=if(Runtime!="00:00:00","Running","Not Running") 
 | stats latest(status) AS Status, latest(Runtime) AS Runtime by Process]
| stats list(Status) as Status list(Runtime) as Runtime by Process
| eval Status=mvindex(Status,-1) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Dec 2016 16:36:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203146#M59013</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-20T16:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203147#M59014</link>
      <description>&lt;P&gt;It's returning a "Not Running"  status and a blank Runtime.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 16:50:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203147#M59014</guid>
      <dc:creator>lloydknight</dc:creator>
      <dc:date>2016-12-20T16:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203148#M59015</link>
      <description>&lt;P&gt;In all cases OR when your base search doesn't have records? Try removing the last stats and check if there are results.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 17:01:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203148#M59015</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-20T17:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203149#M59016</link>
      <description>&lt;P&gt;EDIT:&lt;BR /&gt;
I removed the last stats and the result is Not Running&lt;/P&gt;

&lt;P&gt;In all cases OR when your base search doesn't have records?&lt;BR /&gt;
-didn't get the all cases but yes, even if my base search doesn't have records, they should retain on the table.&lt;/P&gt;

&lt;P&gt;last stats? you mean the base search? Process=process2? tried removing one of it and it didn't disappear on the table. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 17:10:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203149#M59016</guid>
      <dc:creator>lloydknight</dc:creator>
      <dc:date>2016-12-20T17:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203150#M59017</link>
      <description>&lt;P&gt;No. If your base search has records for both process1 and process2 (you need to update the first portion to put exact process name that you're using in your query), following search should return you 4 rows. If your base search has only one records, total records from below will be 2 and if your base search has no records, you'll still get 2 records with status Not Running (default value chosed in first search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval Process="process1##process2" | table Process | eval Status="Not Running" 
 | makemv Process delim="##" | mvexpand Process
 | append [ search index=myindex host=server1 source=mysource
  | multikv
  | search Process=process1 OR Process=process2
  | eval status=if(Runtime!="00:00:00","Running","Not Running") 
  | stats latest(status) AS Status, latest(Runtime) AS Runtime by Process]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Dec 2016 17:14:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203150#M59017</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-20T17:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203151#M59018</link>
      <description>&lt;P&gt;I'm getting the default value (Not Running) even though my base search (process1 and process2) have records. Am I missing something here?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 17:31:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203151#M59018</guid>
      <dc:creator>lloydknight</dc:creator>
      <dc:date>2016-12-20T17:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my eval statement to output a certain value, even if there is no result for a certain field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203152#M59019</link>
      <description>&lt;P&gt;apologies for accepting this answer late. this worked for me. thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 21:07:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-eval-statement-to-output-a-certain-value-even-if/m-p/203152#M59019</guid>
      <dc:creator>lloydknight</dc:creator>
      <dc:date>2017-02-17T21:07:49Z</dc:date>
    </item>
  </channel>
</rss>

