<?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: is eval the right choice? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26032#M4992</link>
    <description>&lt;P&gt;You need to have a pipe between the evals.&lt;/P&gt;

&lt;P&gt;...| stats blaha | eval x=y/z | eval q=w/e&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
    <pubDate>Thu, 12 Apr 2012 20:05:42 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2012-04-12T20:05:42Z</dc:date>
    <item>
      <title>is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26027#M4987</link>
      <description>&lt;P&gt;The query below displays accurate values for Requests, Accepted, Rejected and %Accepted. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count(eval(nps_packetType=1)) AS "Requests", 
  count(eval(nps_packetType=2)) AS "Accepted", 
  count(eval(nps_packetType=3)) AS "Rejected" 
| eval %Accepted=round((Accepted/Requests*100))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can add a code similar to below so it also calculates &amp;amp; displays %Rejected&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval %Rejected=round((Rejected/Requests*100))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, I calculated values for Accepted and Rejected only because I believe I need them  to calculate the percentages. But is there a way to NOT display values for Accepted &amp;amp; Rejected?&lt;BR /&gt;
Seems the syntax for EVAL requires I use "AS" which then seems to assume I want the values displayed.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 19:14:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26027#M4987</guid>
      <dc:creator>mikefoti</dc:creator>
      <dc:date>2012-04-12T19:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26028#M4988</link>
      <description>&lt;P&gt;Yes, you can add the &lt;CODE&gt;fields&lt;/CODE&gt; command at the end of the query;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | fields - Rejected, Accepted
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 19:39:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26028#M4988</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-12T19:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26029#M4989</link>
      <description>&lt;P&gt;Thanks Kristian. That answers the 2nd portion of the question. Any idea on the first... how to display %Rejected along with %Accepted??&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 19:41:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26029#M4989</guid>
      <dc:creator>mikefoti</dc:creator>
      <dc:date>2012-04-12T19:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26030#M4990</link>
      <description>&lt;P&gt;I thought you just had all that in one query, i.e. the stats and the two eval statements. Did it not work?&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 19:45:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26030#M4990</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-12T19:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26031#M4991</link>
      <description>&lt;P&gt;No. Trying to simply append this line to the end of the working query does not work.&lt;BR /&gt;
... eval %Rejected=round((Rejected/Requests*100))&lt;/P&gt;

&lt;P&gt;For example, the below fails because of the last EVAL statement.&lt;/P&gt;

&lt;P&gt;| stats count(eval(nps_packetType=1)) AS "Requests", &lt;BR /&gt;
  count(eval(nps_packetType=2)) AS "Accepted", &lt;BR /&gt;
  count(eval(nps_packetType=3)) AS "Rejected" &lt;BR /&gt;
| eval %Accepted=round((Accepted/Requests*100))&lt;BR /&gt;
eval %Rejected=round((Rejected/Requests*100))&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:40:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26031#M4991</guid>
      <dc:creator>mikefoti</dc:creator>
      <dc:date>2020-09-28T11:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26032#M4992</link>
      <description>&lt;P&gt;You need to have a pipe between the evals.&lt;/P&gt;

&lt;P&gt;...| stats blaha | eval x=y/z | eval q=w/e&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 20:05:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26032#M4992</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-12T20:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26033#M4993</link>
      <description>&lt;P&gt;Unfortunately that does not work because both  "eval %Accepted" and "eval $Rejected" need what is piped from the STATS function.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 20:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26033#M4993</guid>
      <dc:creator>mikefoti</dc:creator>
      <dc:date>2012-04-12T20:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26034#M4994</link>
      <description>&lt;P&gt;kristian.kolb's suggestion works just fine. simply make sure you do &lt;CODE&gt;| fields&lt;/CODE&gt; &lt;EM&gt;after&lt;/EM&gt; both evals.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 20:39:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26034#M4994</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-04-12T20:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26035#M4995</link>
      <description>&lt;P&gt;yep, I could have been a bit clearer on that.&lt;/P&gt;

&lt;P&gt;Also, I've never used '%' as part of a field name, could that be causing trouble, need quoting/escaping or something like that?&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 21:33:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26035#M4995</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-12T21:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26036#M4996</link>
      <description>&lt;P&gt;Using "%" in a field name &lt;EM&gt;could&lt;/EM&gt; cause problems in some places, though you can deal with it by enclosing the field name with single quotes. In this case, it's not a problem.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 21:41:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26036#M4996</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-04-12T21:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: is eval the right choice?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26037#M4997</link>
      <description>&lt;P&gt;It all works perfectly now that I do |fields at the right place. Thanks both for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2012 14:44:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-eval-the-right-choice/m-p/26037#M4997</guid>
      <dc:creator>mikefoti</dc:creator>
      <dc:date>2012-04-13T14:44:37Z</dc:date>
    </item>
  </channel>
</rss>

