<?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 Return 0 when &amp;quot;no results found&amp;quot; in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449467#M171443</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;In the following query, I'm hoping to return the value 0 to my dashboard panel if no results are found by the search query.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=test "slice_played" externalUserID="$ext$" assetID!="806d682119ac46d18b9f4a5f3dc20b10" &lt;BR /&gt;
assetID!="5c117f3141244a3a9d6899395b5c65aa" $ass$ &lt;BR /&gt;
| stats sum(duration) as "y_seconds"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Please help! I've tried using the solution asked in a similar question, but to no avail.&lt;/P&gt;</description>
    <pubDate>Wed, 08 May 2019 17:22:17 GMT</pubDate>
    <dc:creator>moizmmz</dc:creator>
    <dc:date>2019-05-08T17:22:17Z</dc:date>
    <item>
      <title>Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449467#M171443</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;In the following query, I'm hoping to return the value 0 to my dashboard panel if no results are found by the search query.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=test "slice_played" externalUserID="$ext$" assetID!="806d682119ac46d18b9f4a5f3dc20b10" &lt;BR /&gt;
assetID!="5c117f3141244a3a9d6899395b5c65aa" $ass$ &lt;BR /&gt;
| stats sum(duration) as "y_seconds"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Please help! I've tried using the solution asked in a similar question, but to no avail.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 17:22:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449467#M171443</guid>
      <dc:creator>moizmmz</dc:creator>
      <dc:date>2019-05-08T17:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449468#M171444</link>
      <description>&lt;P&gt;Please try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt;..
| fillnull value=0 duration 
| stats sum(duration)  as "y_seconds"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 May 2019 18:35:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449468#M171444</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2019-05-08T18:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449469#M171445</link>
      <description>&lt;P&gt;Tried this. Doesn't Work &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 18:41:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449469#M171445</guid>
      <dc:creator>moizmmz</dc:creator>
      <dc:date>2019-05-08T18:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449470#M171446</link>
      <description>&lt;P&gt;please provide some sample data and final output how you want to look like and we could write it for u&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 20:06:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449470#M171446</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2019-05-08T20:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449471#M171447</link>
      <description>&lt;P&gt;Thats the thing though. For now, it returns "No results found". So instead of seeing "No results found" in my dashboard panel, I want to see 0 !!&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 20:14:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449471#M171447</guid>
      <dc:creator>moizmmz</dc:creator>
      <dc:date>2019-05-08T20:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449472#M171448</link>
      <description>&lt;P&gt;@moizmmz- Try below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test "slice_played" externalUserID="$ext$" assetID!="806d682119ac46d18b9f4a5f3dc20b10" assetID!="5c117f3141244a3a9d6899395b5c65aa" $ass$ | append [|makeresults| eval duration=0]|stats sum(duration) as "y_seconds"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 May 2019 20:17:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449472#M171448</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-05-08T20:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449473#M171449</link>
      <description>&lt;P&gt;Hi moizmmz,&lt;/P&gt;

&lt;P&gt;need to trick Splunk for this, because if there are no events Splunk will show &lt;CODE&gt;No results found&lt;/CODE&gt;. So you need to add &lt;EM&gt;fake&lt;/EM&gt; events and do some logic around. Try this run everywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype!=splunkd_* baz
| append 
    [| makeresults 
    | stats count(foo) AS count 
    | eval _raw="Nothing to see here, move along!"] 
| streamstats count AS line_num 
| eval head_num=if((line_num &amp;gt; 1),(line_num - 1),1) 
| where (true() XOR ((count == 0) AND (head_num &amp;lt; line_num))) 
| fields - column, count, head_num, line_num 
| sort -_time | table *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The benefit of this search is that if there are no events it will only show one column with the message &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps to get you started ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;

&lt;P&gt;PS: another example can be found here &lt;A href="https://answers.splunk.com/answers/704513/how-do-i-show-0-when-no-results-are-found-in-a-rep.html"&gt;https://answers.splunk.com/answers/704513/how-do-i-show-0-when-no-results-are-found-in-a-rep.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 20:24:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449473#M171449</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-05-08T20:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449474#M171450</link>
      <description>&lt;P&gt;strange. what i've done is, if the value is empty, put the value to 0. So it will sum up 0 and should show 0. But anyways&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 21:58:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449474#M171450</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2019-05-08T21:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449475#M171451</link>
      <description>&lt;P&gt;Yeah!!! that's exactly what I thought!&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 22:14:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449475#M171451</guid>
      <dc:creator>moizmmz</dc:creator>
      <dc:date>2019-05-08T22:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449476#M171452</link>
      <description>&lt;P&gt;Thanks though &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 22:14:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449476#M171452</guid>
      <dc:creator>moizmmz</dc:creator>
      <dc:date>2019-05-08T22:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 when "no results found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449477#M171453</link>
      <description>&lt;P&gt;Add this to the bottom of your search SPL string:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| appendpipe [stats count | where count=0]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can thank @martin_mueller for this!&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 01:25:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-when-quot-no-results-found-quot/m-p/449477#M171453</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-05-09T01:25:07Z</dc:date>
    </item>
  </channel>
</rss>

