<?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 eval case with comparison operators doesn't return expected result? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153058#M42921</link>
    <description>&lt;P&gt;Thanks for your suggestion.  All is working now.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Oct 2014 23:06:47 GMT</pubDate>
    <dc:creator>hcastell</dc:creator>
    <dc:date>2014-10-06T23:06:47Z</dc:date>
    <item>
      <title>Why eval case with comparison operators doesn't return expected result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153052#M42915</link>
      <description>&lt;P&gt;Hi all, I am using the following search string to determine if a specific value in a table falls between 34 and 50 (pass) or &amp;gt;50 OR &amp;lt;34 (fail):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval DOCSIS_TxPWR_Rdy=case(TestTxPwr=="n/a", "Fail", TestTxPwr &amp;gt;="50" AND TestTxPwr &amp;gt;="34", "Pass", TestTxPwr &amp;gt; "50" OR TestTxPwr &amp;lt; "34", "Fail") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above works fine except when the value us actually =50 then the result show fail.  Trying to figure out what I am missing. A value of 50 should be a pass.  Appreciate any insight you could offer.&lt;/P&gt;

&lt;P&gt;Howard.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2014 16:26:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153052#M42915</guid>
      <dc:creator>hcastell</dc:creator>
      <dc:date>2014-10-06T16:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why eval case with comparison operators doesn't return expected result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153053#M42916</link>
      <description>&lt;P&gt;Correction to my search string:&lt;/P&gt;

&lt;P&gt;| eval DOCSIS_TxPWR_Rdy=case(TestTxPwr=="n/a", "Fail", TestTxPwr &amp;lt;="50" AND TestTxPwr &amp;gt;="34", "Pass", TestTxPwr &amp;gt; "50" OR TestTxPwr &amp;lt; "34", "Fail") &lt;/P&gt;

&lt;P&gt;This is the one I am having issues with.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:48:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153053#M42916</guid>
      <dc:creator>hcastell</dc:creator>
      <dc:date>2020-09-28T17:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why eval case with comparison operators doesn't return expected result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153054#M42917</link>
      <description>&lt;P&gt;Hi @hcastell&lt;/P&gt;

&lt;P&gt;Just taking a stab at this, but would this work for your case?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval DOCSIS_TxPWR_Rdy=case(TestTxPwr=="n/a" OR TestTxPwr &amp;gt; "50" OR TestTxPwr &amp;lt; "34", "Fail", TestTxPwr &amp;lt;="50" AND TestTxPwr &amp;gt;="34", "Pass")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Oct 2014 16:56:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153054#M42917</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2014-10-06T16:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why eval case with comparison operators doesn't return expected result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153055#M42918</link>
      <description>&lt;P&gt;Thanks for your suggestion but the result was the same (ie. still does not work).  Here is the value that I am testing against from the xml file:&lt;/P&gt;

&lt;P&gt;50.0 dBmV&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2014 17:28:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153055#M42918</guid>
      <dc:creator>hcastell</dc:creator>
      <dc:date>2014-10-06T17:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why eval case with comparison operators doesn't return expected result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153056#M42919</link>
      <description>&lt;P&gt;The field that I added to my comment didn't come out properly so let me try again using quotes:&lt;/P&gt;

&lt;P&gt;"50.0 dBmV"&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2014 17:29:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153056#M42919</guid>
      <dc:creator>hcastell</dc:creator>
      <dc:date>2014-10-06T17:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why eval case with comparison operators doesn't return expected result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153057#M42920</link>
      <description>&lt;P&gt;The greater than (&lt;CODE&gt;&amp;gt;&lt;/CODE&gt;) and less than (&lt;CODE&gt;&amp;lt;&lt;/CODE&gt;) do not work for strings, only for numeric fields.&lt;/P&gt;

&lt;P&gt;Therefore, try this instead&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; yoursearchhere
| eval TestTxPwrNum=TestTxPwr
| convert  rmunit(TestTxPwrNum)
| eval DOCSIS_TxPWR_Rdy=case(TestTxPwr=="n/a" OR TestTxPwrNum &amp;gt; 50 OR TestTxPwrNum &amp;lt; 34, "Fail",
     TestTxPwrNum &amp;lt;=50 AND TestTxPwrNum &amp;gt;=34, "Pass")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Oct 2014 17:45:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153057#M42920</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-10-06T17:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why eval case with comparison operators doesn't return expected result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153058#M42921</link>
      <description>&lt;P&gt;Thanks for your suggestion.  All is working now.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2014 23:06:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-eval-case-with-comparison-operators-doesn-t-return-expected/m-p/153058#M42921</guid>
      <dc:creator>hcastell</dc:creator>
      <dc:date>2014-10-06T23:06:47Z</dc:date>
    </item>
  </channel>
</rss>

