<?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: Return 0 If Search Returns &amp;quot;No Results Found&amp;quot; in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287198#M86946</link>
    <description>&lt;P&gt;thanks, this helped me&lt;/P&gt;</description>
    <pubDate>Thu, 26 Mar 2020 15:04:55 GMT</pubDate>
    <dc:creator>airalee</dc:creator>
    <dc:date>2020-03-26T15:04:55Z</dc:date>
    <item>
      <title>Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287189#M86937</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I am trying to make it so that when a search string returns the "No Results Found" message, it actually displays a zero.&lt;/P&gt;

&lt;P&gt;Here's what I am trying to achieve. I have a single value panel. I have this panel display the sum of login failed events from a search string. However, when there are no events to return, it simply puts "No results found" or "N/A". I want this to display a 0 as it is much easier on the eye (you know there were no results as opposed to thinking "did my search fail?").&lt;/P&gt;

&lt;P&gt;Here's the search I have so far that will either return the sum of all failed login events, or the "No results found" message:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=infrastructure
sourcetype=linux_secure
"Too many authentiction failures"
| rex "failures for (?&amp;lt;account&amp;gt;[\w\.]+)"
| search account=* host=*
| stats count as failures by account
| stats sum(failures) as sub_failures
| eval total_failures = if(isnull(sub_failures),"0",sub_failures
| fields total_failuress
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It will return the total number of login failed events if any are generated. However if there are none, it will display "No results found" hwere I really want it to just display 0.&lt;/P&gt;

&lt;P&gt;Anyone willing to help a buried Splunker &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 11:10:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287189#M86937</guid>
      <dc:creator>Bytes</dc:creator>
      <dc:date>2015-12-22T11:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287190#M86938</link>
      <description>&lt;P&gt;Use the fillnull command before  your last eval:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1511/SearchReference/Fillnull"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.1511/SearchReference/Fillnull&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 11:22:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287190#M86938</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2015-12-22T11:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287191#M86939</link>
      <description>&lt;P&gt;Didn't work I'm affraid. I believe this is because there are no events to perform the stats functions on.&lt;/P&gt;

&lt;P&gt;I am essentially telling it to count the events, but if there are no events to count then I think the stats functions won't create any inititated variables (so no variables with NULL to fill with fillnull).&lt;/P&gt;

&lt;P&gt;I tried to fill any nulls after the first stats function with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fillnull value=0 failures
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this didn't work. I have looked around the other answers but cannot find one that helps me in my case.&lt;/P&gt;

&lt;P&gt;Any other ideas by chance?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 11:35:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287191#M86939</guid>
      <dc:creator>Bytes</dc:creator>
      <dc:date>2015-12-22T11:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287192#M86940</link>
      <description>&lt;P&gt;Succes! Fill null did work just needed a tweak.&lt;/P&gt;

&lt;P&gt;Here's the code that provided the 0 I was after:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=infrastructure
sourcetype=linux_secure
"Too many authentiction failures"
| rex "failures for (?&amp;lt;account&amp;gt;[\w\.]+)"
| search account=* host=*
| stats count as failures
| fillnull
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This problem seems to be casued by me grouping by accounts (as I was reusing my code from another search string).&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 11:43:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287192#M86940</guid>
      <dc:creator>Bytes</dc:creator>
      <dc:date>2015-12-22T11:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287193#M86941</link>
      <description>&lt;P&gt;If you think outside the box a little you could use the panel display feature in the dashboard to just show a different/dummy display when there are no results returned.&lt;/P&gt;

&lt;P&gt;For instance I have some single value metrics on a dashboard that normally show N/A if there are no results returned and it also makes the overall panel look a bit untidy.&lt;/P&gt;

&lt;P&gt;So I did this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      &amp;lt;single depends="$result1$"&amp;gt;
        &amp;lt;title&amp;gt;'Share' Tracking&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| inputlookup user_usage.csv  | search "click on \\\"SHARE\\\"" (name="Toll_DPM_BT_PADATA_DETAILEDUSERACTIONS_AllEnv") (application="*")  NOT (GomezAgent) UserName!="*tollgroup.com" | timechart count span=7d&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-30d@d&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;progress&amp;gt;
            &amp;lt;condition match="'job.resultCount' &amp;lt; 1"&amp;gt;
              &amp;lt;set token="fill1"&amp;gt;true&amp;lt;/set&amp;gt;
              &amp;lt;unset token="result1"&amp;gt;&amp;lt;/unset&amp;gt;
            &amp;lt;/condition&amp;gt;
            &amp;lt;condition&amp;gt;
              &amp;lt;set token="result1"&amp;gt;&amp;lt;/set&amp;gt;
              &amp;lt;unset token="fill1"&amp;gt;true&amp;lt;/unset&amp;gt;
            &amp;lt;/condition&amp;gt;
          &amp;lt;/progress&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;all&amp;lt;/option&amp;gt;
        &amp;lt;option name="colorBy"&amp;gt;value&amp;lt;/option&amp;gt;
        &amp;lt;option name="colorMode"&amp;gt;block&amp;lt;/option&amp;gt;
        &amp;lt;option name="numberPrecision"&amp;gt;0&amp;lt;/option&amp;gt;
        &amp;lt;option name="rangeColors"&amp;gt;["0x65a637","0x65a637"]&amp;lt;/option&amp;gt;
        &amp;lt;option name="rangeValues"&amp;gt;[1]&amp;lt;/option&amp;gt;
        &amp;lt;option name="showSparkline"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="showTrendIndicator"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="trendColorInterpretation"&amp;gt;standard&amp;lt;/option&amp;gt;
        &amp;lt;option name="trendDisplayMode"&amp;gt;absolute&amp;lt;/option&amp;gt;
        &amp;lt;option name="unitPosition"&amp;gt;after&amp;lt;/option&amp;gt;
        &amp;lt;option name="useColors"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="useThousandSeparators"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="link.visible"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="underLabel"&amp;gt;Compared to Previous Week&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.time.visible"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;drilldown&amp;gt;
          &amp;lt;set token="detail-track"&amp;gt;true&amp;lt;/set&amp;gt;
        &amp;lt;/drilldown&amp;gt;
      &amp;lt;/single&amp;gt;
      &amp;lt;single depends="$fill1$"&amp;gt;
        &amp;lt;title&amp;gt;'Share' Tracking&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| inputlookup fillnull.csv  | timechart count span=7d&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-30d@d&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="colorBy"&amp;gt;trend&amp;lt;/option&amp;gt;
        &amp;lt;option name="colorMode"&amp;gt;block&amp;lt;/option&amp;gt;
        &amp;lt;option name="numberPrecision"&amp;gt;0&amp;lt;/option&amp;gt;
        &amp;lt;option name="rangeColors"&amp;gt;["0x65a637","0x65a637"]&amp;lt;/option&amp;gt;
        &amp;lt;option name="rangeValues"&amp;gt;[1]&amp;lt;/option&amp;gt;
        &amp;lt;option name="showSparkline"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="showTrendIndicator"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="trendColorInterpretation"&amp;gt;standard&amp;lt;/option&amp;gt;
        &amp;lt;option name="trendDisplayMode"&amp;gt;absolute&amp;lt;/option&amp;gt;
        &amp;lt;option name="unitPosition"&amp;gt;after&amp;lt;/option&amp;gt;
        &amp;lt;option name="useColors"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="useThousandSeparators"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="link.visible"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="underLabel"&amp;gt;Compared to Previous Week&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.time.visible"&amp;gt;false&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The top box shows if there is a result returned and the bottom one shows a dummy result containing zeros if there is no results returned.&lt;/P&gt;

&lt;P&gt;The lookup table fillnull.csv would just be something like this&lt;/P&gt;

&lt;P&gt;_time   count&lt;BR /&gt;
date       0&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 05:37:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287193#M86941</guid>
      <dc:creator>proylea</dc:creator>
      <dc:date>2016-10-21T05:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287194#M86942</link>
      <description>&lt;P&gt;This doesn't work if I'm using timechart instead of stats since I need to show the trend.&lt;BR /&gt;
Any ideas?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2017 17:12:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287194#M86942</guid>
      <dc:creator>guarisma</dc:creator>
      <dc:date>2017-02-24T17:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287195#M86943</link>
      <description>&lt;P&gt;Do you have to constantly update the fillnull.csv with a new date?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2017 17:15:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287195#M86943</guid>
      <dc:creator>guarisma</dc:creator>
      <dc:date>2017-02-24T17:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287196#M86944</link>
      <description>&lt;P&gt;From my understanding, the whole point of using stats at the end of the query is to populate a result for count rather than seeing "No Results Found."  Why would you want to do this?  For me, I used this as an opportunity to substitute the value "0" for a customized message by using eval.  For instance, if inputlookup can't find any results you could tell others to manually search elsewhere or in my case, I defined a conditional value to look for the message.  If this condition was met, you could click on the message and it would direct you to a place where you could find what you're looking for.  Unfortunately it does not work with timechart, streamstats, eventstats, etc. because they rely on results to be generated.  Stats works because it generates a result even if the count is zero.  How are you going to show a trend if there are no results?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup &amp;lt;table&amp;gt; WHERE &amp;lt;search&amp;gt; | fields &amp;lt;field2&amp;gt; &amp;lt;field1&amp;gt; &amp;lt;field3&amp;gt;  | appendpipe [stats count] | eval &amp;lt;field&amp;gt;=if(isnull(&amp;lt;field&amp;gt;),"&amp;lt;message&amp;gt;",&amp;lt;field&amp;gt;) | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My example used inputlookup for the search.  Fields was used to reorder the table.  Appendpipe was used to join stats with the initial search so that the following eval statement would work.  Without appending the results, the eval statement would never work even though the designated field was null.  Stats served its purpose by generating a result for count=0.  Before removing the field, the eval statement substituted a null value for one of the fields with a customized message.  Finally, the final pipe removed the count field since it was no longer needed.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 10:32:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287196#M86944</guid>
      <dc:creator>Nextbeat</dc:creator>
      <dc:date>2018-04-25T10:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287197#M86945</link>
      <description>&lt;P&gt;Try this adding at the end of query.&lt;/P&gt;

&lt;P&gt;index.... sourcetype.....  |appendpipe [stats count | where count==0]&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Sai &lt;BR /&gt;
,Try this adding at the end of query.&lt;/P&gt;

&lt;P&gt;index=...... sourctype......   |appendpipe [stats count | where count==0]&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
sai kiran&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 17:49:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287197#M86945</guid>
      <dc:creator>nagaramsai</dc:creator>
      <dc:date>2019-07-30T17:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287198#M86946</link>
      <description>&lt;P&gt;thanks, this helped me&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 15:04:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/287198#M86946</guid>
      <dc:creator>airalee</dc:creator>
      <dc:date>2020-03-26T15:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/513316#M144012</link>
      <description>&lt;P&gt;For me, that works but causes dashboard panels to use the max range colours for some reason.&lt;/P&gt;&lt;P data-unlink="true"&gt;I've posted about it here: https://community.splunk.com/t5/Splunk-Search/Append-causing-dashboard-panels-to-use-colours-for-max-ranges/td-p/513293&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 11:41:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/513316#M144012</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-08-10T11:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/513319#M144014</link>
      <description>&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/How-to-change-a-single-panel-color-based-on-text-result-with/m-p/513120/highlight/true#M143965" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Search/How-to-change-a-single-panel-color-based-on-text-result-with/m-p/513120/highlight/true#M143965&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/224768"&gt;@benhooper&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;how about this?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 11:53:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/513319#M144014</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-10T11:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/522344#M147286</link>
      <description>&lt;PRE&gt;index=infrastructure
sourcetype=linux_secure
"Too many authentiction failures"
| rex "failures for (?&amp;lt;account&amp;gt;[\w\.]+)"
| search account=* host=*
| stats count as failures by account
| stats sum(failures) &lt;/PRE&gt;&lt;P&gt;I know this is an old post, but like me, I ran into this same problem.&amp;nbsp; This is how I solved it, by adding: after the | stats sum&lt;BR /&gt;| appendpipe [| stats count as failures | where failures=0 ]&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 19:10:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/522344#M147286</guid>
      <dc:creator>jason_hotchkiss</dc:creator>
      <dc:date>2020-09-30T19:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706258#M239023</link>
      <description>&lt;P&gt;So glad to see nearly a decade on Splunk still has no way around this issue &lt;span class="lia-unicode-emoji" title=":pile_of_poo:"&gt;💩&lt;/span&gt;🤯🤪&lt;span class="lia-unicode-emoji" title=":litter_in_bin_sign:"&gt;🚮&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Unbelievable...&lt;BR /&gt;&lt;BR /&gt;How hard is it to return a 0 value if there are just no samples within a timespan?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Dec 2024 13:29:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706258#M239023</guid>
      <dc:creator>julienbonastre</dc:creator>
      <dc:date>2024-12-08T13:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706276#M239026</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/274693"&gt;@julienbonastre&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;thanks for your concern, however some of latest responses for this thread&amp;nbsp; responses posted work for this query in splunk community&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;BR /&gt;also&amp;nbsp;This question was posted a while ago and might not get the attention you need for your own question to be answered. I suggest you please post a brand new question so your issue can get more visibility.&lt;BR /&gt;&lt;BR /&gt;Anyways, I am also giving other posts&amp;nbsp; urls where it is solved. hope&amp;nbsp;this helps&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304352" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304352&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/How-can-I-resolve-return-0-for-quot-No-Results-Found-quot/m-p/645819" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/How-can-I-resolve-return-0-for-quot-No-Results-Found-quot/m-p/645819&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Display-result-0-rather-than-quot-No-Results-Found-quot/m-p/511204" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/Display-result-0-rather-than-quot-No-Results-Found-quot/m-p/511204&lt;/A&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 08 Dec 2024 17:14:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706276#M239026</guid>
      <dc:creator>SanjayReddy</dc:creator>
      <dc:date>2024-12-08T17:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706285#M239028</link>
      <description>&lt;P&gt;Adding to &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236694"&gt;@SanjayReddy&lt;/a&gt; 's answer I'll take the opportunity to explain why this actually makes sense.&lt;/P&gt;&lt;P&gt;Firstly, Splunk executes search commands in a pipeline. Each subsequent command knows only the results from the previous step. That's why you have to make sure you have all the data you need for further processing at each step and you can't reference any data you've already filtered out or in any other way "lost" along the way.&lt;/P&gt;&lt;P&gt;Secondly, if stats count were to return 0 in case it got no events on input it would have to be implemented as an explicit exception to a normal stats behaviour. Remember that there are much more aggregation functions than just count for stats and for at least some of them returning a value for zero input rows would make no sense. Like average=0 is definitely not the same as no result at all.&lt;/P&gt;&lt;P&gt;Thirdly, even count can be over some field. How is stats supposed to know whatever values should be expected in those fields?&lt;/P&gt;&lt;P&gt;So this behaviour while maybe a bit inconvenient to handle (actually, it could be worth posting an idea for a generalized "default result" command if there isn't one yet; haven't checked it) it is consistent with the overall stats mechanics.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Dec 2024 21:00:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706285#M239028</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-12-08T21:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706295#M239031</link>
      <description>&lt;P&gt;Wow thanks for rapid responses&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236694"&gt;@SanjayReddy&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏🏼&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Didn't expect such turnaround on my vent in this dead/old thread.&lt;/P&gt;&lt;P&gt;However I really do appreciate the constructive feedback, and I certainly do understand the justification for why the stats/timechart functions as it does, it's just a shame I've been trawling most of those other linked threads and many hours of google searches to find many different suggested approaches, none which oddly seem to fit the bill for what is actually a fairly small, simple query/resultant expectation..&lt;/P&gt;&lt;P&gt;It's one of those things you just think, meh, this takes 30 secs in ANSI SQL, noSQL or any other RDBMS to produce the desired resultant matrix/vector, but in Splunk, I need my masters in SPL &lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, thank you again, wholeheartedly appreciate your positive and responsive attitudes given my pretty low-contribution post &lt;span class="lia-unicode-emoji" title=":hugging_face:"&gt;🤗&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I will check those threads you've provided which I haven't looked at before and if all else fails, as you've suggested, I'll post afresh &lt;span class="lia-unicode-emoji" title=":rocket:"&gt;🚀&lt;/span&gt;🥰&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 01:18:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706295#M239031</guid>
      <dc:creator>julienbonastre</dc:creator>
      <dc:date>2024-12-09T01:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706296#M239032</link>
      <description>&lt;P&gt;Just to reiterate here the general simple solution to this issue in case it gets read again, which has already been posted in this thread.&lt;/P&gt;&lt;P&gt;All you need to do is to add the appendpipe clause to the end of the search like this - where "NOUSER" is assumed not to exist, so without the appendpipe, will return no results found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_audit user=NOUSER
| appendpipe [
  | stats count
  | where count=0
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 03:13:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706296#M239032</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-12-09T03:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706297#M239033</link>
      <description>&lt;P&gt;And a technique I use a reasonable amount in dashboards is to have a panel for results and a panel for no results hidden behind tokens, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form version="1.1" theme="light"&amp;gt;
  &amp;lt;label&amp;gt;tmp4&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="text" token="user" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;User&amp;lt;/label&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html depends="$no_results$"&amp;gt;
        &amp;lt;h1&amp;gt;No results found&amp;lt;/h1&amp;gt;
      &amp;lt;/html&amp;gt;
      &amp;lt;table depends="$has_results$"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;progress&amp;gt;
            &amp;lt;unset token="has_results"&amp;gt;&amp;lt;/unset&amp;gt;
            &amp;lt;unset token="no_results"&amp;gt;&amp;lt;/unset&amp;gt;
          &amp;lt;/progress&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;eval token="has_results"&amp;gt;if($job.resultCount$=0, null(), "true")&amp;lt;/eval&amp;gt;
            &amp;lt;eval token="no_results"&amp;gt;if($job.resultCount$&amp;amp;gt;0, null(), "true")&amp;lt;/eval&amp;gt;
          &amp;lt;/done&amp;gt;
          &amp;lt;query&amp;gt;index=_audit user=$user|s$&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;100&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 09 Dec 2024 03:25:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706297#M239033</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-12-09T03:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Return 0 If Search Returns "No Results Found"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706298#M239034</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;, yes, this is the typical "solution" I've seen around, however this does not work on `timechart` and similar time bucket constrained expressions.&lt;/P&gt;&lt;P&gt;Certainly if one is after just a solve for `stats` this definitely does work.&lt;/P&gt;&lt;P&gt;This is my query:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* source=squid_proxy_logs 
|  search (warn* OR error*) AND _raw!="*SendEcho*" AND (NOT url=*) AND _raw!="*setrlimit: RLIMIT_NOFILE*"
| timechart span=5m count(_raw) as hits&lt;/LI-CODE&gt;&lt;P&gt;I've tried appendpipe, append etc tricks with a variety of expressions such as:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| appendpipe [| makeresults | where hits=0]

| appendpipe [|makeresults | stats count(_raw) as count | where count=0 ]&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;and a few other alternates I've seen around, but all have the same issue, they work great on a single vector stats return result being null/empty, but with the timechart this doesn't really play well unfortunately..&lt;BR /&gt;&lt;BR /&gt;I think the closest I can get is where I have to makeresults myself into the spans and bins I need and then use a query to aggregate the counts into those predefined bins I've carved up, and these bins of course would be generated based on the search query timerange so it would work for historical periods as well as realtime ...&lt;BR /&gt;&lt;BR /&gt;Just need to rejig my query I think to do something like this so it &lt;STRONG&gt;always&lt;/STRONG&gt; produces a fixed matrix/tabular output and with the respective count values for that point in time, rather than trying to build a dataset from where there are just zero values to start with (as is the case if there are NO records matching)... so it &lt;EM&gt;kinda&lt;/EM&gt; makes sense why this happens...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 03:25:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-0-If-Search-Returns-quot-No-Results-Found-quot/m-p/706298#M239034</guid>
      <dc:creator>julienbonastre</dc:creator>
      <dc:date>2024-12-09T03:25:39Z</dc:date>
    </item>
  </channel>
</rss>

