<?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 Rounding anomaly? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193191#M55593</link>
    <description>&lt;P&gt;I'm getting what I believe are strange results when using the round function to control the number of decimal places.  This is a search that I have in a dashboard to calculate how much data (in GB) that I have indexed in the last 24 hours:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" source="*metrics.log" per_index_thruput| eval GB=kb/1024/1024 | stats sum(GB) as total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result of the above search is: 7.8531551056447.  I wanted to round to 2 decimal places so I modified the search to use the round function like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" source="*metrics.log" per_index_thruput| eval GB=round((kb/1024/1024),2) | stats sum(GB) as total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, the result of the above search is: 0.15 (instead of 7.85).  So, I tried the same search but this time to 3 decimal places like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" source="*metrics.log" per_index_thruput| eval GB=round((kb/1024/1024),3) | stats sum(GB) as total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result of the above search is: 7.21 which is closer to the expected result of 7.85 but still not 100% accurate.&lt;/P&gt;

&lt;P&gt;So, I tried 4 decimal places like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" source="*metrics.log" per_index_thruput| eval GB=round((kb/1024/1024),4) | stats sum(GB) as total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the result of the above search is 7.8405 which is almost accurate/correct.  But, I don't want 4 decimal places...&lt;/P&gt;

&lt;P&gt;What am I doing wrong, why does the search with 2 decimal places return 0.15?  Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 18 Mar 2014 20:15:40 GMT</pubDate>
    <dc:creator>echojacques</dc:creator>
    <dc:date>2014-03-18T20:15:40Z</dc:date>
    <item>
      <title>Rounding anomaly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193191#M55593</link>
      <description>&lt;P&gt;I'm getting what I believe are strange results when using the round function to control the number of decimal places.  This is a search that I have in a dashboard to calculate how much data (in GB) that I have indexed in the last 24 hours:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" source="*metrics.log" per_index_thruput| eval GB=kb/1024/1024 | stats sum(GB) as total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result of the above search is: 7.8531551056447.  I wanted to round to 2 decimal places so I modified the search to use the round function like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" source="*metrics.log" per_index_thruput| eval GB=round((kb/1024/1024),2) | stats sum(GB) as total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, the result of the above search is: 0.15 (instead of 7.85).  So, I tried the same search but this time to 3 decimal places like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" source="*metrics.log" per_index_thruput| eval GB=round((kb/1024/1024),3) | stats sum(GB) as total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result of the above search is: 7.21 which is closer to the expected result of 7.85 but still not 100% accurate.&lt;/P&gt;

&lt;P&gt;So, I tried 4 decimal places like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" source="*metrics.log" per_index_thruput| eval GB=round((kb/1024/1024),4) | stats sum(GB) as total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the result of the above search is 7.8405 which is almost accurate/correct.  But, I don't want 4 decimal places...&lt;/P&gt;

&lt;P&gt;What am I doing wrong, why does the search with 2 decimal places return 0.15?  Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 20:15:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193191#M55593</guid>
      <dc:creator>echojacques</dc:creator>
      <dc:date>2014-03-18T20:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding anomaly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193192#M55594</link>
      <description>&lt;P&gt;Try this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" source="*metrics.log" per_index_thruput| eval GB=kb/1024/1024 | stats sum(GB) as total | eval sum(GB)=round(sum(GB),2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Mar 2014 22:17:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193192#M55594</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-03-18T22:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding anomaly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193193#M55595</link>
      <description>&lt;P&gt;Thanks but I got the following error when I tried this search:&lt;/P&gt;

&lt;P&gt;Error in 'eval' command: The 'sum' function is unsupported or undefined.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 22:32:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193193#M55595</guid>
      <dc:creator>echojacques</dc:creator>
      <dc:date>2014-03-18T22:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding anomaly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193194#M55596</link>
      <description>&lt;P&gt;My bad. replace eval stmt with this.&lt;/P&gt;

&lt;P&gt;|eval total==round(total,2)&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 04:07:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193194#M55596</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-03-19T04:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding anomaly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193195#M55597</link>
      <description>&lt;P&gt;This is not yet an answer, just informational: last November we did open a case with support because of this &lt;CODE&gt;eval&lt;/CODE&gt; example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main | eval result=0.2-0 | head 10 | table result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This example shows the calculation of 0.2 minus 0, which gives 0.2, looks good so far ... but, when we multiply 0 with 0.1 first, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main | eval result=0.2-(0*0.1) | head 10 | table result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which should end up in 0.2 as well (0 * 0.1 is 0, 0.2 minus 0 is 0.2). But Splunk gives back zero (0) instead.&lt;/P&gt;

&lt;P&gt;Update: This will be handled in SPL-76889, eval multiplication with 0.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 06:49:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193195#M55597</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-03-19T06:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding anomaly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193196#M55598</link>
      <description>&lt;P&gt;The |eval total=round(total,2) works great and doesn't have the same problem as my original search.  Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 16:07:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193196#M55598</guid>
      <dc:creator>echojacques</dc:creator>
      <dc:date>2014-03-19T16:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding anomaly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193197#M55599</link>
      <description>&lt;P&gt;Interesting, thanks for the info!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 16:10:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193197#M55599</guid>
      <dc:creator>echojacques</dc:creator>
      <dc:date>2014-03-19T16:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding anomaly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193198#M55600</link>
      <description>&lt;P&gt;update ping&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2014 10:18:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193198#M55600</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-03-20T10:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding anomaly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193199#M55601</link>
      <description>&lt;P&gt;Very interesting. It seems Splunk is rounding off "0.2" to integer (0 decimal) and thus giving 0. Used "0.5" or "0.45" gave me 1.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2014 19:09:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-anomaly/m-p/193199#M55601</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-03-20T19:09:44Z</dc:date>
    </item>
  </channel>
</rss>

