<?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: Count of zero and non zero values in a table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408442#M117893</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
| bucket span=30m _time 
| chart count(people) by IP _time limit=500
| sort _time
| eval zeroCount=0. count=0
| foreach 15* [ eval count = count + 1, zeroCount = zeroCount + if(($&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;$ == 0, 1, 0) ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Nov 2018 16:22:16 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2018-11-21T16:22:16Z</dc:date>
    <item>
      <title>Count of zero and non zero values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408441#M117892</link>
      <description>&lt;P&gt;I have a search which generates a table as below. The column value is epoch time.&lt;/P&gt;

&lt;P&gt;IP  1542682800  1542684600  1542686400  1542688200  1542690000  1542691800  1542693600&lt;BR /&gt;
10.7.13.1   0   0   0   59  84  51  0&lt;BR /&gt;
10.7.13.2   0   61  140 103 136 102 0&lt;BR /&gt;
10.7.14.3   0   0   0   0   0   0   0&lt;BR /&gt;
10.7.15.4   0   0   22  6   3   0   0&lt;BR /&gt;
10.7.15.5   60  12  138 84  15  0   0&lt;BR /&gt;
10.7.34.6   0   0   0   0   0   0   0&lt;BR /&gt;
10.7.34.7   0   0   0   0   0   0   0&lt;/P&gt;

&lt;P&gt;Search is like this :&lt;BR /&gt;
base search |&lt;BR /&gt;
| bucket span=30m _time &lt;BR /&gt;
| chart  count(people) by IP _time limit=500 | sort _time&lt;/P&gt;

&lt;P&gt;I am trying to add two columns which would have the count of zero and non-zero values for a particular IP. Any help with this is appreciated. &lt;/P&gt;

&lt;P&gt;So for the 1st row above will have zero count 4 and non zero count 3 and so on for each row.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 03:36:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408441#M117892</guid>
      <dc:creator>mihikaraj</dc:creator>
      <dc:date>2018-11-21T03:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Count of zero and non zero values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408442#M117893</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
| bucket span=30m _time 
| chart count(people) by IP _time limit=500
| sort _time
| eval zeroCount=0. count=0
| foreach 15* [ eval count = count + 1, zeroCount = zeroCount + if(($&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;$ == 0, 1, 0) ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Nov 2018 16:22:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408442#M117893</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-11-21T16:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Count of zero and non zero values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408443#M117894</link>
      <description>&lt;P&gt;Thanks @woodcock. Gives me what I was expecting with a little tweak in the syntax. &lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 22:30:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408443#M117894</guid>
      <dc:creator>mihikaraj</dc:creator>
      <dc:date>2018-11-21T22:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Count of zero and non zero values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408444#M117895</link>
      <description>&lt;P&gt;@woodcock, Is there a way to have a new row at the bottom which is  average of that column values? I tried using foreach but not able to.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 00:58:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408444#M117895</guid>
      <dc:creator>mihikaraj</dc:creator>
      <dc:date>2018-11-23T00:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Count of zero and non zero values in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408445#M117896</link>
      <description>&lt;P&gt;Add this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| appendpipe [ stats avg(zeroCount) AS zeroCount ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Nov 2018 04:31:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-of-zero-and-non-zero-values-in-a-table/m-p/408445#M117896</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-11-23T04:31:45Z</dc:date>
    </item>
  </channel>
</rss>

