<?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: Replacing &amp;quot;No Results Found&amp;quot; with &amp;quot;0&amp;quot; in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/504939#M141331</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt;&amp;nbsp;&lt;EM&gt;your query is what I exactly looking for . Thank you so much&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jun 2020 10:24:32 GMT</pubDate>
    <dc:creator>dharudiya</dc:creator>
    <dc:date>2020-06-18T10:24:32Z</dc:date>
    <item>
      <title>Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304352#M141317</link>
      <description>&lt;P&gt;I have the below query:&lt;/P&gt;
&lt;P&gt;My Search query returns a value when it finds some result whereas when it doesn't find any matching events it returns as "No Results Found".&lt;BR /&gt;Now, I would like to display as "0" instead of "No Results Found" and return the values if it gets any events as before.&lt;/P&gt;
&lt;P&gt;Sample search query:&lt;/P&gt;
&lt;P&gt;| chart count AS event_count by text&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 22:32:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304352#M141317</guid>
      <dc:creator>santosh_hb</dc:creator>
      <dc:date>2020-06-22T22:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304353#M141318</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;can you please try below search??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| chart count AS event_count by text | append [| stats count as event_count]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With above search, you will get text field BLANK, bcoz we don't have a data. If you want to place any static value into text fields then use below search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| chart count AS event_count by text | append [| stats count as event_count| eval text="YOUR TEXT"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I hope this will help you&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 11:31:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304353#M141318</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-10-12T11:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304354#M141319</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/193814"&gt;@santosh_hb&lt;/a&gt;, you have several options to handle no data found scenario gracefully. As stated by &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;, handling the same using &lt;CODE&gt;append&lt;/CODE&gt;and &lt;CODE&gt;dedup&lt;/CODE&gt; is one of the options. Other one is to use &lt;CODE&gt;$job.resultCount$&lt;/CODE&gt; to fin out whether the search returned results and then set/unset token to show/hide required data/panel (get &lt;CODE&gt;Splunk Dashboard Example&lt;/CODE&gt; app which explains this scenario).&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://wiki.splunk.com/images/b/bf/HandleNoResultsScenario.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Following is the run anywhere search for attached screenshot:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Replace No Results with zero&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="time" token="tokTime" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Option 1 - Handler using append in Splunk Search&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd log_level="ERROR"
| chart count as Counter by log_level
| append [| makeresults 
              | eval log_level="ERROR"
              | eval Counter=0
              | fields - _time]
| dedup log_level&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$tokTime.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$tokTime.latest$&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;20&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;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Option 2 - Handler using $job.resultCount$ and depends/rejects attributes&amp;lt;/title&amp;gt;
      &amp;lt;table depends="$tokShowResults$"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd log_level="ERROR"
| chart count as Counter by log_level&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$tokTime.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$tokTime.latest$&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;condition match="$job.resultCount$==0"&amp;gt;
              &amp;lt;unset token="tokShowResults"&amp;gt;&amp;lt;/unset&amp;gt;
            &amp;lt;/condition&amp;gt;
            &amp;lt;condition&amp;gt;
              &amp;lt;set token="tokShowResults"&amp;gt;true&amp;lt;/set&amp;gt;
            &amp;lt;/condition&amp;gt;
          &amp;lt;/done&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&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="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;html rejects="$tokShowResults$"&amp;gt;
        &amp;lt;div style="font-weight:bold;color:red;font-size:150%;text-align:center"&amp;gt;No Results! Please expand search window.&amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:09:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304354#M141319</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T16:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304355#M141320</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;, &lt;CODE&gt;| dedup text&lt;/CODE&gt; needs to be added to your current search. In case event_count by certain text is returned, you need pick only the one returned by search and not the default zero count appended through append command.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:09:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304355#M141320</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T16:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304356#M141321</link>
      <description>&lt;P&gt;@kamlesh_vaghela  - Using &lt;CODE&gt;appendpipe&lt;/CODE&gt;, rather than &lt;CODE&gt;append&lt;/CODE&gt;, will execute the pipeline against the current record set, and add the new results onto the end.  &lt;/P&gt;

&lt;P&gt;Then, if there are any results, you can delete the record you just created, thus adding it only if the prior result set is empty.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | appendpipe [| stats count as event_count| eval text="YOUR TEXT" | where event_count = 0 ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;FYI @niketnilay, this strategy is instead of &lt;CODE&gt;dedup&lt;/CODE&gt;, rather than in addition.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 15:27:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304356#M141321</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-12T15:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304357#M141322</link>
      <description>&lt;P&gt;@DalJeanis, yes I agree and I first tested with &lt;CODE&gt;appendpipe&lt;/CODE&gt;, but I was getting two rows appended when result was found. So I tried &lt;CODE&gt;append&lt;/CODE&gt; as we need to add just one as default. Thanks for pitching in.&lt;/P&gt;

&lt;P&gt;Shouldn't final pipe be  &lt;CODE&gt;| search event_count=0&lt;/CODE&gt; rather than &lt;CODE&gt;where&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 16:34:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304357#M141322</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-12T16:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304358#M141323</link>
      <description>&lt;P&gt;@niketnilay - &lt;CODE&gt;search&lt;/CODE&gt; and &lt;CODE&gt;where&lt;/CODE&gt; would be equivalent in the &lt;CODE&gt;appendpipe&lt;/CODE&gt; pipeline I posted.  That code can only add either one or zero records.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 16:51:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304358#M141323</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-12T16:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304359#M141324</link>
      <description>&lt;P&gt;@niketnilay, i tried you solution of adding the tokens , it works but when there are results i can still see the HTML messages. &lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 15:22:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304359#M141324</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-06-29T15:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304360#M141325</link>
      <description>&lt;P&gt;@macadminrohit for us to assist you further, we would need to see your Simple XML code.&lt;/P&gt;

&lt;P&gt;search event handler for timechart and the depends and rejects tokens that have been applied on timechart and html panel respectively. Since this is a question from last year, I would recommend you posting a new question with the required details.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jun 2018 05:52:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304360#M141325</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-06-30T05:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304361#M141326</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;</description>
      <pubDate>Sun, 01 Jul 2018 02:31:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304361#M141326</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-07-01T02:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304362#M141327</link>
      <description>&lt;P&gt;@woodcock, works like a charm, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 07:47:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304362#M141327</guid>
      <dc:creator>ebruozys</dc:creator>
      <dc:date>2018-08-28T07:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304363#M141328</link>
      <description>&lt;P&gt;I got this from @martin_mueller.  Be sure to click &lt;CODE&gt;Accept&lt;/CODE&gt; if this is the best solution and &lt;CODE&gt;UpVote&lt;/CODE&gt; anybody who helped or has other working solutions.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 13:18:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304363#M141328</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-08-28T13:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304364#M141329</link>
      <description>&lt;P&gt;Hey, @santosh_hb, come back here and click &lt;CODE&gt;Accept&lt;/CODE&gt; to close your question!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 17:24:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304364#M141329</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-08T17:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304365#M141330</link>
      <description>&lt;P&gt;@niketnilay and @DalJeanis I have a similar situation here but unable to implement the solution suggested. I am using &lt;CODE&gt;| stats count by X, Y&lt;/CODE&gt; at the end of my query. X has 4 possible values and so does Y resulting in 16 different combinations. I need a count of 0 for each combination that doesn't exist&lt;/P&gt;

&lt;P&gt;I am trying &lt;CODE&gt;| appendpipe [| stats count by X, Y | where count = 0]&lt;/CODE&gt; to get additional rows with 0  count but it is not working.  Can you please tell me what have I misunderstood here?&lt;/P&gt;

&lt;P&gt;I can post a new question if required. I wrote it as a comment as I thought it is very relevant here.&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 10:09:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/304365#M141330</guid>
      <dc:creator>vinaysathyanara</dc:creator>
      <dc:date>2020-02-13T10:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/504939#M141331</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt;&amp;nbsp;&lt;EM&gt;your query is what I exactly looking for . Thank you so much&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 10:24:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/504939#M141331</guid>
      <dc:creator>dharudiya</dc:creator>
      <dc:date>2020-06-18T10:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "No Results Found" with "0"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/660370#M227962</link>
      <description>&lt;P&gt;what if I want to print 100.00% instead of zero&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 09:46:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replacing-quot-No-Results-Found-quot-with-quot-0-quot/m-p/660370#M227962</guid>
      <dc:creator>Siddharthnegi</dc:creator>
      <dc:date>2023-10-11T09:46:32Z</dc:date>
    </item>
  </channel>
</rss>

