<?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: Include zero in the average in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311516#M93357</link>
    <description>&lt;P&gt;See above, the problem was related to &amp;lt;&amp;gt; values  in ReqMonthAva.&lt;/P&gt;

&lt;P&gt;Tks!&lt;BR /&gt;
Carmine&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jan 2018 08:09:33 GMT</pubDate>
    <dc:creator>CarmineCalo</dc:creator>
    <dc:date>2018-01-19T08:09:33Z</dc:date>
    <item>
      <title>Include zero in the average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311512#M93353</link>
      <description>&lt;P&gt;Splunkers!&lt;/P&gt;

&lt;P&gt;I'm not able to solve a strange issue...&lt;/P&gt;

&lt;P&gt;Basically, the stats avg() is omitting values in the calculation.&lt;/P&gt;

&lt;P&gt;Code is the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;&amp;lt;search&amp;gt;&amp;gt;

| fillnull Incident_Duration,Unavailabilty_Month value=0
| stats avg(Incident_Duration) as Incident_Avg, avg(Unavailabilty_Month) as Unavailabilty_Avg by ReqMonthAva, AppID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, null value are transformed into 0 in the table resulting from the previous search, but avg function is not considering them while processing Incident_Avg and Unavailabilty_Avg&lt;/P&gt;

&lt;P&gt;Seems to me very strange... how can i solve?&lt;/P&gt;

&lt;P&gt;Tks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:41:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311512#M93353</guid>
      <dc:creator>CarmineCalo</dc:creator>
      <dc:date>2020-09-29T17:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Include zero in the average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311513#M93354</link>
      <description>&lt;P&gt;can you try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;&amp;lt;search&amp;gt;&amp;gt;

 | fillnull
 | stats avg(Incident_Duration) as Incident_Avg, avg(Unavailabilty_Month) as Unavailabilty_Avg by ReqMonthAva, AppID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jan 2018 18:54:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311513#M93354</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-18T18:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Include zero in the average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311514#M93355</link>
      <description>&lt;P&gt;can you try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ..|eval Incident_Duration=tonumber(Incident_Duration), Unavailabilty_Month=tonumber(Unavailabilty_Month)
 | fillnull Incident_Duration,Unavailabilty_Month value=0
 | stats avg(Incident_Duration) as Incident_Avg, avg(Unavailabilty_Month) as Unavailabilty_Avg by ReqMonthAva, AppID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i think it might be that your values are strings and not numbers. using this runanywhere command: &lt;CODE&gt;|makeresults|eval data=" ,2,1,4,6"|makemv delim="," data|mvexpand data|eval with_zero=tonumber(data)|fillnull with_zero value=0|stats avg(data) avg(with_zero)&lt;/CODE&gt;, the values are different.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2018 19:20:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311514#M93355</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2018-01-18T19:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Include zero in the average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311515#M93356</link>
      <description>&lt;P&gt;It works!&lt;/P&gt;

&lt;P&gt;I found the root problem... basically RegMonthAva had some &amp;lt;&amp;gt; value  (corresponding with &amp;lt;&amp;gt; values for Unavailability_month and Incident_Duration).&lt;/P&gt;

&lt;P&gt;With | fillnull i solve the problem.&lt;/P&gt;

&lt;P&gt;Tks!&lt;/P&gt;

&lt;P&gt;Carmine&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:41:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311515#M93356</guid>
      <dc:creator>CarmineCalo</dc:creator>
      <dc:date>2020-09-29T17:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Include zero in the average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311516#M93357</link>
      <description>&lt;P&gt;See above, the problem was related to &amp;lt;&amp;gt; values  in ReqMonthAva.&lt;/P&gt;

&lt;P&gt;Tks!&lt;BR /&gt;
Carmine&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 08:09:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311516#M93357</guid>
      <dc:creator>CarmineCalo</dc:creator>
      <dc:date>2018-01-19T08:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Include zero in the average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311517#M93358</link>
      <description>&lt;P&gt;I am glad that my solution helped you to get the desired results. I am converting my comment to an answer. Accept/upvote it if this is an answer to your question!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 08:10:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Include-zero-in-the-average/m-p/311517#M93358</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-19T08:10:43Z</dc:date>
    </item>
  </channel>
</rss>

