<?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: stats median does not work with 0 value in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615228#M14060</link>
    <description>&lt;P&gt;For median calculation, I considered only disinct values and not all values!&lt;/P&gt;&lt;P&gt;This was a wrong way to calculate&lt;/P&gt;</description>
    <pubDate>Thu, 29 Sep 2022 14:50:49 GMT</pubDate>
    <dc:creator>segantinro</dc:creator>
    <dc:date>2022-09-29T14:50:49Z</dc:date>
    <item>
      <title>Why does stats median does not work with 0 value?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615206#M14054</link>
      <description>&lt;P&gt;I need to personalize the "Data Processing Queues" monitored made by Monitoring Console.&lt;/P&gt;
&lt;P&gt;I found that "median" aggregate function, on stats or timechart commands does not work correctly.&lt;/P&gt;
&lt;P&gt;Indeed, launching the following search, over "all time" on&amp;nbsp; my PC (host=localhost), I obtain that median is 0 if on values there is a 0.&lt;/P&gt;
&lt;P&gt;In the example attached, the correct median is 0.73, instead Splunk calculate 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(group=queue host=localhost index=_internal name=* source=*metrics.log sourcetype=splunkd)
| eval ingest_pipe=if(isnotnull(ingest_pipe),ingest_pipe,"none")
| search ingest_pipe=*
| where match(name,"agg")
| eval max=if(isnotnull(max_size_kb),max_size_kb,max_size), curr=if(isnotnull(current_size_kb),current_size_kb,current_size), fill_perc=round(((curr / max) * 100),2)
| timechart minspan=30s Median(fill_perc) values(fill_perc) avg(fill_perc) useother=false limit=15&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="median.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21769i162079333D0D54E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="median.png" alt="median.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone else found this issue ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 14:54:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615206#M14054</guid>
      <dc:creator>segantinro</dc:creator>
      <dc:date>2022-09-29T14:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: stats median does not work with 0 value</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615214#M14055</link>
      <description>&lt;P&gt;&lt;STRONG&gt;your previous search until&amp;nbsp;time chart command&lt;BR /&gt;| timechart minspan=30s values(fill_perc) as values_fill_perc avg(fill_perc)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| eventstats median(values_fill_perc) by _time&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| rename values_fill_perc as "values(fill_perc)"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The eventstats command uses the multivalue field creates by the values() aggregate function and adds a new column to the table.&lt;/P&gt;&lt;P&gt;Warning: This will give you the Median of existent values and not the actual median over all events in the database. &amp;nbsp;(see comment from&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;)&lt;/P&gt;&lt;P&gt;_______________________________________&lt;/P&gt;&lt;P&gt;If this was helpful please consider awarding Karma. Thx!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 14:20:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615214#M14055</guid>
      <dc:creator>FelixLeh</dc:creator>
      <dc:date>2022-09-29T14:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: stats median does not work with 0 value</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615215#M14056</link>
      <description>&lt;P&gt;It is quite possible that this is correct, given that your avg is 0.11 and you have quite a few values above that so there must be quite a few values below that to drive the mean down to 0.11&lt;/P&gt;&lt;P&gt;Try listing all the values to see if the median is right&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| timechart minspan=30s Median(fill_perc) list(fill_perc) avg(fill_perc) useother=false limit=15&lt;/LI-CODE&gt;&lt;P&gt;You could also try counting them&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 14:04:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615215#M14056</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-09-29T14:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: stats median does not work with 0 value</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615219#M14058</link>
      <description>&lt;P&gt;I concur with&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;. Use list and you'll see all the zeros in your data set.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 14:12:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615219#M14058</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-09-29T14:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: stats median does not work with 0 value</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615228#M14060</link>
      <description>&lt;P&gt;For median calculation, I considered only disinct values and not all values!&lt;/P&gt;&lt;P&gt;This was a wrong way to calculate&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 14:50:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-stats-median-does-not-work-with-0-value/m-p/615228#M14060</guid>
      <dc:creator>segantinro</dc:creator>
      <dc:date>2022-09-29T14:50:49Z</dc:date>
    </item>
  </channel>
</rss>

