<?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: Can AND or OR be used in case statements in eval expressions? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46658#M11148</link>
    <description>&lt;P&gt;Ayn,&lt;BR /&gt;
This does not work at least with timechart&lt;/P&gt;</description>
    <pubDate>Wed, 09 May 2012 15:30:29 GMT</pubDate>
    <dc:creator>joegrossman</dc:creator>
    <dc:date>2012-05-09T15:30:29Z</dc:date>
    <item>
      <title>Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46655#M11145</link>
      <description>&lt;P&gt;Right now I have a search that contains c(eval(status&amp;lt;=400)) AS SUCCESS c(eval(status&amp;gt;400)) AS FAILURE.&lt;BR /&gt;
This works, producing a chart of failures and sucesses. But now I want to change it so it has a WARNING category. This would include only status=404. But to do this I would have to change the FAILURE category to something like, status&amp;gt;400 AND status !=404. But the case statement does not seem to allow this. &lt;BR /&gt;
Can anyone help me with this?&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2012 20:51:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46655#M11145</guid>
      <dc:creator>joegrossman</dc:creator>
      <dc:date>2012-05-08T20:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46656#M11146</link>
      <description>&lt;P&gt;Which case statement?&lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;eval&lt;/CODE&gt; statement supports this. All you have to do is something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats c(eval(status&amp;gt;400 AND status!=404)) AS FAILURE
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 May 2012 21:06:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46656#M11146</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-05-08T21:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46657#M11147</link>
      <description>&lt;P&gt;Another approach might be to use a lookup table that has all the various HTTP response codes and the resulting status you wish them to have.  You'd have to enumerate them and specify a value for each, but it is workable.&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 01:49:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46657#M11147</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2012-05-09T01:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46658#M11148</link>
      <description>&lt;P&gt;Ayn,&lt;BR /&gt;
This does not work at least with timechart&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 15:30:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46658#M11148</guid>
      <dc:creator>joegrossman</dc:creator>
      <dc:date>2012-05-09T15:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46659#M11149</link>
      <description>&lt;P&gt;Or you can do it through &lt;CODE&gt;rangemap&lt;/CODE&gt;...  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... |  rangemap field=status SUCCESS=0-399 WARNING=404-404 default=FAILURE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you have the information in the newly created field '&lt;CODE&gt;range&lt;/CODE&gt;'.&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 16:09:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46659#M11149</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-05-09T16:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46660#M11150</link>
      <description>&lt;P&gt;But it does! I just tried it myself.&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 17:39:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46660#M11150</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-05-09T17:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46661#M11151</link>
      <description>&lt;P&gt;The question was not answered (which seems to be the normal):&lt;/P&gt;

&lt;P&gt;So, is: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
eval var1 = case(A==0 AND B==1, "ZeroOne",&lt;BR /&gt;
                 A==1 AND B==0, "OneZero",&lt;BR /&gt;
                 1==1, "Neither")&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Supposed to be a valid construct? &lt;/P&gt;

&lt;P&gt;In my case i can't get it to work. It's either the default branch (1==1) or NULL.&lt;/P&gt;

&lt;P&gt;Any hints?&lt;/P&gt;

&lt;P&gt;Dirk&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2013 16:07:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46661#M11151</guid>
      <dc:creator>dvl077</dc:creator>
      <dc:date>2013-02-05T16:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46662#M11152</link>
      <description>&lt;P&gt;I can get it to work with the following search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=access_combined status=404 OR status=200 
| dedup 3 status 
| eval tt=if(time_taken&amp;lt;500, "1", "0") 
| eval var1 = case(status==200 AND tt=1, "A", status==404 AND tt==0, "B", 1&amp;gt;0, "C") 
| table status tt var1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For sake of clarity/completeness, I've included the complete search I used. The first three lines are just for getting event data (based off access_combined) to work on, so they don't have any real purpose besides that. &lt;/P&gt;

&lt;P&gt;The results table looks like;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status  tt  var1
404     1   C
200     1   A
404     0   B
200     0   C
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2013 21:39:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46662#M11152</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-02-05T21:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46663#M11153</link>
      <description>&lt;P&gt;I confirm, the boolean expression in case() works. My problem was the following:&lt;/P&gt;

&lt;P&gt;To gather one of the needed values to decide on i did the following:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
| eval no-value-supplied = if(isnull(mkfind(msisdn, "no-value-supplied")), 1, 0)&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Note that the introduced variable and the constant string in the mkfind are identical.&lt;/P&gt;

&lt;P&gt;Interesting is:&lt;/P&gt;

&lt;P&gt;if you output the variable, e.g. via "table no-value-supplied" the value binding is correct (1 or 0 in this case). &lt;/P&gt;

&lt;P&gt;Using no-value-supplied in a boolean statement inside of case &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
| eval new_var = case(no-value-supplied == 1 AND ....)&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;never yields true.&lt;/P&gt;

&lt;P&gt;Is this a bug, or did i miss something in the documentation?&lt;/P&gt;

&lt;P&gt;Renaming the variable fixed the issue.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2013 16:03:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46663#M11153</guid>
      <dc:creator>dvl077</dc:creator>
      <dc:date>2013-02-06T16:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46664#M11154</link>
      <description>&lt;P&gt;While I can totally appreciate frustration, please remember that most splunk-base participants do not work for Splunk and are answering people's questions on a completely volunteer basis.  I don't think your "which seems to be normal" comment is fair to those who do spend a lot of time trying to offer free help on here.  Splunk has paid support options available to you if the community is not able to help you solve your problems.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2013 16:22:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46664#M11154</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2013-02-06T16:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46665#M11155</link>
      <description>&lt;P&gt;My experience is that dashes can sometimes be confused for subtract. As a point of habit, I separate words in my field names with underscore.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2013 16:29:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46665#M11155</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2013-02-06T16:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46666#M11156</link>
      <description>&lt;P&gt;It was just a observation, no critique of the participants was implied.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2013 16:33:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46666#M11156</guid>
      <dc:creator>dvl077</dc:creator>
      <dc:date>2013-02-06T16:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can AND or OR be used in case statements in eval expressions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46667#M11157</link>
      <description>&lt;P&gt;like truth, observations are not always productive or good.  also, paid-support can be quite slow and unhelpful as well, in far too many cases.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 13:53:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-AND-or-OR-be-used-in-case-statements-in-eval-expressions/m-p/46667#M11157</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2016-01-05T13:53:52Z</dc:date>
    </item>
  </channel>
</rss>

