<?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: Why does multiple eval statements cause only last to be run? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388639#M113326</link>
    <description>&lt;P&gt;Or you can make one long case / if:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  sourcetype="mytraffic"
  | chart count as Count by Channel
  | eval MeetThreshold=if((Count&amp;lt;=4 AND Channel=="Web"),"Fail",if((Count&amp;lt;=400 AND Channel=="Mobile"),"Fail","Pass")))
  | table Channel Count MeetThreshold

  sourcetype="mytraffic"
  | chart count as Count by Channel
  | eval MeetThreshold=case(
   Count&amp;lt;=4 AND Channel=="Web","Fail",
   Count&amp;lt;=400 AND Channel=="Mobile","Fail",
   1=1,"Pass")
  | table Channel Count MeetThreshold
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 15 Jul 2019 18:41:26 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2019-07-15T18:41:26Z</dc:date>
    <item>
      <title>Why does multiple eval statements cause only last to be run?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388637#M113324</link>
      <description>&lt;P&gt;I am trying to create a low volume type of alert based on one sourcetype for multiple Channels that have very different amounts of traffic.  The search I am using is as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="mytraffic"
| chart count as Count by Channel
| eval MeetThreshold?=if((Count&amp;lt;=4) AND (Channel=="Web"),"Fail","Pass")
| eval MeetThreshold?=if((Count&amp;lt;=400) AND (Channel=="Mobile"),"Fail","Pass")
| table Channel Count MeetThreshold?
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In my tests, it seems the results only reflect the status of the last eval statement.  Is there a better way to do this?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 18:26:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388637#M113324</guid>
      <dc:creator>markhvesta</dc:creator>
      <dc:date>2019-07-15T18:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why does multiple eval statements cause only last to be run?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388638#M113325</link>
      <description>&lt;P&gt;Thats because your defining the same field name.  try this approach instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype="mytraffic"
 | chart count as Count by Channel
 | eval MeetThreshold1=if((Count&amp;lt;=4) AND (Channel=="Web"),"Fail","Pass")
 | eval MeetThreshold2=if((Count&amp;lt;=400) AND (Channel=="Mobile"),"Fail","Pass")
 | eval MeetThreshold=coalesc(MeetThreshold1,MeetThreshold2)
 | table Channel Count MeetThreshold
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jul 2019 18:38:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388638#M113325</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-07-15T18:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why does multiple eval statements cause only last to be run?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388639#M113326</link>
      <description>&lt;P&gt;Or you can make one long case / if:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  sourcetype="mytraffic"
  | chart count as Count by Channel
  | eval MeetThreshold=if((Count&amp;lt;=4 AND Channel=="Web"),"Fail",if((Count&amp;lt;=400 AND Channel=="Mobile"),"Fail","Pass")))
  | table Channel Count MeetThreshold

  sourcetype="mytraffic"
  | chart count as Count by Channel
  | eval MeetThreshold=case(
   Count&amp;lt;=4 AND Channel=="Web","Fail",
   Count&amp;lt;=400 AND Channel=="Mobile","Fail",
   1=1,"Pass")
  | table Channel Count MeetThreshold
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jul 2019 18:41:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388639#M113326</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-07-15T18:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why does multiple eval statements cause only last to be run?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388640#M113327</link>
      <description>&lt;P&gt;You need to use &lt;CODE&gt;case&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="mytraffic"
| chart count as Count by Channel
| eval MeetThreshold=case(
   (Count&amp;lt;=4) AND (Channel=="Web"), "Fail",
   (Count&amp;lt;=400) AND (Channel=="Mobile"), "Fail",
   true(), "Pass")
| table Channel Count MeetThreshold
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jul 2019 19:22:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388640#M113327</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-15T19:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why does multiple eval statements cause only last to be run?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388641#M113328</link>
      <description>&lt;P&gt;That is perfect.  Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 20:57:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-multiple-eval-statements-cause-only-last-to-be-run/m-p/388641#M113328</guid>
      <dc:creator>markhvesta</dc:creator>
      <dc:date>2019-07-15T20:57:56Z</dc:date>
    </item>
  </channel>
</rss>

