<?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 incorrect use of eval? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686858#M234258</link>
    <description>&lt;P&gt;Hi, I'm new to Splunk, so I apologize if this question seems naive.&lt;/P&gt;&lt;P&gt;While experimenting with calculated fields, I found some inconsistent results. Consequently, I removed these fields and tested directly in the search.&lt;/P&gt;&lt;P&gt;I'm aware that the syntax I'm using here with eval is not the one specified in the documentation, but I'm using it to simulate the calculated field (and it yields the same results). I've seen this use of eval elsewhere but only for very simple things.&lt;/P&gt;&lt;P&gt;When I run:&lt;/P&gt;&lt;PRE&gt;stats sum(eval((bytes/(1024*1024)))) as MB&lt;/PRE&gt;&lt;P&gt;, it works. However, when I run&lt;/P&gt;&lt;PRE&gt;stats sum(eval(round(bytes/(1024*1024),2))) as MB&lt;/PRE&gt;&lt;P&gt;I get results, but they are totally inconsistent.&lt;/P&gt;&lt;P&gt;What could be happening? Where is my mistake? (Note that I'm not looking for the correct solution - I already have it - but I want to understand why this syntax doesn't work.)&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Wed, 08 May 2024 09:58:20 GMT</pubDate>
    <dc:creator>FromTheGraves</dc:creator>
    <dc:date>2024-05-08T09:58:20Z</dc:date>
    <item>
      <title>incorrect use of eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686858#M234258</link>
      <description>&lt;P&gt;Hi, I'm new to Splunk, so I apologize if this question seems naive.&lt;/P&gt;&lt;P&gt;While experimenting with calculated fields, I found some inconsistent results. Consequently, I removed these fields and tested directly in the search.&lt;/P&gt;&lt;P&gt;I'm aware that the syntax I'm using here with eval is not the one specified in the documentation, but I'm using it to simulate the calculated field (and it yields the same results). I've seen this use of eval elsewhere but only for very simple things.&lt;/P&gt;&lt;P&gt;When I run:&lt;/P&gt;&lt;PRE&gt;stats sum(eval((bytes/(1024*1024)))) as MB&lt;/PRE&gt;&lt;P&gt;, it works. However, when I run&lt;/P&gt;&lt;PRE&gt;stats sum(eval(round(bytes/(1024*1024),2))) as MB&lt;/PRE&gt;&lt;P&gt;I get results, but they are totally inconsistent.&lt;/P&gt;&lt;P&gt;What could be happening? Where is my mistake? (Note that I'm not looking for the correct solution - I already have it - but I want to understand why this syntax doesn't work.)&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 09:58:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686858#M234258</guid>
      <dc:creator>FromTheGraves</dc:creator>
      <dc:date>2024-05-08T09:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect use of eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686862#M234261</link>
      <description>&lt;P&gt;Interesting... Is it a different result every time you run it or at least the same different results for the same input?&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 10:17:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686862#M234261</guid>
      <dc:creator>apietsch</dc:creator>
      <dc:date>2024-05-08T10:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect use of eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686863#M234262</link>
      <description>&lt;P&gt;In what way are they inconsistent? (The totals are most likely different due to the rounding)&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 10:20:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686863#M234262</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-08T10:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect use of eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686873#M234267</link>
      <description>&lt;P&gt;Rounding errors?&lt;/P&gt;&lt;P&gt;When you're doing&lt;/P&gt;&lt;PRE&gt;stats sum(eval(round(bytes/(1024*1024),2))) as MB&lt;/PRE&gt;&lt;P&gt;You lose some part of the value since you're "cutting off" the part after two decimal digits.&lt;/P&gt;&lt;P&gt;So the error is expected.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 11:22:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686873#M234267</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-05-08T11:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect use of eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686882#M234270</link>
      <description>&lt;P class="lia-align-justify"&gt;Okay, good point, I must have left my brain somewhere far away...&lt;/P&gt;&lt;P class="lia-align-justify"&gt;Indeed, max(bytes) is 47KB and avg is 2KB, less than 1MB!&lt;/P&gt;&lt;P class="lia-align-justify"&gt;Thank you all for your responsiveness.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 12:34:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/incorrect-use-of-eval/m-p/686882#M234270</guid>
      <dc:creator>FromTheGraves</dc:creator>
      <dc:date>2024-05-08T12:34:36Z</dc:date>
    </item>
  </channel>
</rss>

