<?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 round stats average to 2 decimal places? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174036#M49919</link>
    <description>&lt;P&gt;This especially works well when you are using a split by statement.&lt;BR /&gt;
EG:&lt;BR /&gt;
| stats avg(eval(round(count,0))) AS Avg_Count by something&lt;/P&gt;</description>
    <pubDate>Wed, 03 Apr 2019 15:28:59 GMT</pubDate>
    <dc:creator>damiensurat</dc:creator>
    <dc:date>2019-04-03T15:28:59Z</dc:date>
    <item>
      <title>How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174031#M49914</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I have this:&lt;/P&gt;

&lt;P&gt;stats count by opentime | stats avg(count)&lt;/P&gt;

&lt;P&gt;and I want the average to be in 2dp.&lt;/P&gt;

&lt;P&gt;Anyone have any suggestions?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2014 12:50:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174031#M49914</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2014-10-22T12:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174032#M49915</link>
      <description>&lt;P&gt;Here is how I do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;stats count by opentime | stats avg(count) as avg_count | eval avg_count=round(avg_count,2) | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Oct 2014 13:21:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174032#M49915</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-10-22T13:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174033#M49916</link>
      <description>&lt;P&gt;if you really like the name &lt;CODE&gt;avg(count)&lt;/CODE&gt; I believe you can do it by quoting the name:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats avg(count) | eval 'avg(count)'=round('avg(count)',2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Oct 2014 16:37:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174033#M49916</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2014-10-22T16:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174034#M49917</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have tried the above but this is not working for me. Could anyone please tell me why round function is not working for me.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 05:51:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174034#M49917</guid>
      <dc:creator>AdsicSplunk</dc:creator>
      <dc:date>2018-03-12T05:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174035#M49918</link>
      <description>&lt;P&gt;I know this has been around a while, but I felt I should share this with the community.  You can incorporate the eval statement into the stats command:&lt;BR /&gt;
EG:&lt;BR /&gt;
      | stats avg(eval(round(count,0))) AS Avg_Count&lt;/P&gt;

&lt;P&gt;[&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.5/Search/Usestatswithevalexpressionsandfunctions"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.5/Search/Usestatswithevalexpressionsandfunctions&lt;/A&gt;]&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 15:27:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174035#M49918</guid>
      <dc:creator>damiensurat</dc:creator>
      <dc:date>2019-04-03T15:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174036#M49919</link>
      <description>&lt;P&gt;This especially works well when you are using a split by statement.&lt;BR /&gt;
EG:&lt;BR /&gt;
| stats avg(eval(round(count,0))) AS Avg_Count by something&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 15:28:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174036#M49919</guid>
      <dc:creator>damiensurat</dc:creator>
      <dc:date>2019-04-03T15:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174037#M49920</link>
      <description>&lt;P&gt;I know this has been around a while, but I felt I should share this with the community. You can incorporate the eval statement into the stats command:&lt;BR /&gt;
EG:&lt;BR /&gt;
| stats avg(eval(round(count,2))) AS Avg_Count&lt;/P&gt;

&lt;P&gt;[&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.5/Search/Usestatswithevalexpressionsandfunctions"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.5/Search/Usestatswithevalexpressionsandfunctions&lt;/A&gt;]&lt;/P&gt;

&lt;P&gt;This especially works well when you are using a split by statement.&lt;BR /&gt;
EG:&lt;BR /&gt;
| stats avg(eval(round(count,2))) AS Avg_Count by something&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 15:31:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174037#M49920</guid>
      <dc:creator>damiensurat</dc:creator>
      <dc:date>2019-04-03T15:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174038#M49921</link>
      <description>&lt;P&gt;It didn't actually round the average for me. I think that rounds the count or a field value before applying the average.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 21:44:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174038#M49921</guid>
      <dc:creator>bschandramohan</dc:creator>
      <dc:date>2019-09-16T21:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174039#M49922</link>
      <description>&lt;P&gt;I downvoted this post because does not work, since it round the number before its averaged.  It will not round the result.   Look at this   round((4+5)/2) is not the same as (round(4)+round(5))/2&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 18:42:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174039#M49922</guid>
      <dc:creator>lakromani</dc:creator>
      <dc:date>2019-09-30T18:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174040#M49923</link>
      <description>&lt;P&gt;very useful, thanks @damiensurat &lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 11:09:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/174040#M49923</guid>
      <dc:creator>brettcave</dc:creator>
      <dc:date>2020-01-30T11:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/537057#M151813</link>
      <description>&lt;P&gt;This is great - is there an equivalent way to do with with mstats searches? This syntax doesn't seem to work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 13:58:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/537057#M151813</guid>
      <dc:creator>gene_tien</dc:creator>
      <dc:date>2021-01-25T13:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to round stats average to 2 decimal places?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/542286#M153610</link>
      <description>&lt;P&gt;Using eval in stats works, but if you want to round the average, you have to eval(round(avg(count),2)).&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 05:00:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-stats-average-to-2-decimal-places/m-p/542286#M153610</guid>
      <dc:creator>esalesap</dc:creator>
      <dc:date>2021-03-04T05:00:47Z</dc:date>
    </item>
  </channel>
</rss>

