<?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 display a 0 result instead an empty result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393567#M172901</link>
    <description>&lt;P&gt;if it works, please accept my answer.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Feb 2019 13:09:41 GMT</pubDate>
    <dc:creator>vnravikumar</dc:creator>
    <dc:date>2019-02-21T13:09:41Z</dc:date>
    <item>
      <title>how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393557#M172891</link>
      <description>&lt;P&gt;hi&lt;/P&gt;

&lt;P&gt;I use the search below and I would like to have a 0 results displayed when there is no events corresponding&lt;BR /&gt;
could you help me please?? Thanks&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    eventtype="x" Name="x" 
    | fields Name, host 
    | dedup host
    | stats count by host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 10:48:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393557#M172891</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-02-21T10:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393558#M172892</link>
      <description>&lt;P&gt;This is one way to do it. First create a CSV of all the valid hosts you want to show with a zero value. Call this hosts.csv and make sure it has a column called "host". Then change the query to be like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; eventtype="x" Name="x" 
| fields Name, host 
| dedup host
| stats count by host
| append [|inputlookup hosts.csv]
| stats sum(count) as count by host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 10:54:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393558#M172892</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2019-02-21T10:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393559#M172893</link>
      <description>&lt;P&gt;A more elegant way would be to use a combination of stats and eval. Please try this run anywhere example which I am sure can be customized for your use case. Also, instead of doing dedup and then count, dc(distinct count) can be used.&lt;/P&gt;

&lt;P&gt;Try replacing log_level with DEBUG or any non standard type in the search to see it returns 0.&lt;/P&gt;

&lt;P&gt;index=_internal sourcetype=splunkd log_level="ERROR"&lt;BR /&gt;
|fields component,host&lt;BR /&gt;
|stats dc(eval(if(isnull(host),0,host))) AS Count&lt;/P&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:19:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393559#M172893</guid>
      <dc:creator>vik_splunk</dc:creator>
      <dc:date>2020-09-29T23:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393560#M172894</link>
      <description>&lt;P&gt;Hi @jip31&lt;/P&gt;

&lt;P&gt;Try this and let me know&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype="x" Name="x" 
     | fields Name, host 
     | dedup host
     | stats count by host
     | appendpipe [stats count | where count=0 | eval host="Specify your text here"]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 11:37:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393560#M172894</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-02-21T11:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393561#M172895</link>
      <description>&lt;P&gt;@jip31, have you tried?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 12:43:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393561#M172895</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-02-21T12:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393562#M172896</link>
      <description>&lt;P&gt;thank but its impossible to use a lookup...&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 12:44:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393562#M172896</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-02-21T12:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393563#M172897</link>
      <description>&lt;P&gt;thanks&lt;BR /&gt;
if i put only appendpipe [stats count | where count=0] its enough?&lt;BR /&gt;
what is the use of eval host="Specify your text here"]??&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 12:53:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393563#M172897</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-02-21T12:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393564#M172898</link>
      <description>&lt;P&gt;yes its enough, but under host column it will display empty. If you want to add some text info, you can specify&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 12:56:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393564#M172898</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-02-21T12:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393565#M172899</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/102660"&gt;@jip31&lt;/a&gt; &lt;/P&gt;

&lt;P&gt;An elegant way to do this without lookups would be to use eval and stats as can be seen in this run anywhere example which I am sure can be customized for your use case.&lt;/P&gt;

&lt;P&gt;Also, you won't require dedup followed by stats as dc(distinct count) does the same and fields can be used to return only the field you count upon as the filter has been done earlier.&lt;/P&gt;

&lt;P&gt;index=_internal sourcetype=splunkd log_level="ERROR"&lt;BR /&gt;
|fields host&lt;BR /&gt;
|stats dc(eval(if(isnull(host),0,host))) AS Count&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:19:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393565#M172899</guid>
      <dc:creator>vik_splunk</dc:creator>
      <dc:date>2020-09-29T23:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393566#M172900</link>
      <description>&lt;P&gt;ok its not a problem because I done a fields - host&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 13:06:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393566#M172900</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-02-21T13:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393567#M172901</link>
      <description>&lt;P&gt;if it works, please accept my answer.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 13:09:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393567#M172901</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-02-21T13:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393568#M172902</link>
      <description>&lt;P&gt;@jip31 &lt;/P&gt;

&lt;P&gt;Which solution worked for you?&lt;/P&gt;

&lt;P&gt;The stats or the lookup based solution?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 17:18:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393568#M172902</guid>
      <dc:creator>vik_splunk</dc:creator>
      <dc:date>2019-02-21T17:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393569#M172903</link>
      <description>&lt;P&gt;sorry but I have an issue it works but even if there is results I have...........0 instead results...&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 14:04:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393569#M172903</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-02-22T14:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393570#M172904</link>
      <description>&lt;P&gt;Thanks its interesting&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:22:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393570#M172904</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-02-22T17:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to display a 0 result instead an empty result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393571#M172905</link>
      <description>&lt;P&gt;Thé stats but if there is event i have also 0 instead résult...&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:24:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-display-a-0-result-instead-an-empty-result/m-p/393571#M172905</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-02-22T17:24:54Z</dc:date>
    </item>
  </channel>
</rss>

