<?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: What's wrong with this case statement? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602635#M209765</link>
    <description>&lt;P&gt;One way to see what those fields contains is a create a new field like&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
| eval contains="&amp;gt;" . field . "&amp;lt;"
| ...&lt;/LI-CODE&gt;&lt;P&gt;That way it's not needed to guess what that field contains.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jun 2022 14:02:35 GMT</pubDate>
    <dc:creator>isoutamo</dc:creator>
    <dc:date>2022-06-21T14:02:35Z</dc:date>
    <item>
      <title>What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602492#M209718</link>
      <description>&lt;P&gt;When I add this case statement to my search, all results for Severity are "Other". What did I miss?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Severity=case(score&amp;gt;=0.1 AND score&amp;lt;=3.9, "Low", score&amp;gt;=4.0 AND score&amp;lt;=6.9, "Medium", score&amp;gt;=7.0 AND score&amp;lt;=8.9, "High", score&amp;gt;=9.0 AND score&amp;lt;=10.0, "Critical", true(), "Other")&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 22:06:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602492#M209718</guid>
      <dc:creator>mistydennis</dc:creator>
      <dc:date>2022-06-20T22:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602535#M209739</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201395"&gt;@mistydennis&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;sometimes I found problems in dots management, so I hint to try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Severity=case(score&amp;gt;0 AND score&amp;lt;4, "Low", score&amp;gt;=4 AND score&amp;lt;7, "Medium", score&amp;gt;=7 AND score&amp;lt;9, "High", score&amp;gt;=9 AND score&amp;lt;=10, "Critical", true(), "Other")&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 06:34:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602535#M209739</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-06-21T06:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602538#M209740</link>
      <description>&lt;P&gt;If your fields which contain "numbers" misbehave it's often the case of the fields being in fact string representations of numbers. Try eval-ing the field before your case to a number using&lt;/P&gt;&lt;PRE&gt;| eval score=tonumber(score)&lt;/PRE&gt;&lt;P&gt;Oh, and assuming all your scores are non-negative, you can limit your number of conditions since they are evaluated left to right until a match is found. So if the first condition (0.1 - 3.9) evaluates to false, there is no point of requiring the number to be at least 4.0 in the next step because if it was smaller, it would have matched the first condition.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 06:42:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602538#M209740</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-06-21T06:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602541#M209742</link>
      <description>&lt;P&gt;In verbose mode you can check the type of field from selected/interesting field columns. If before the field name is # =&amp;gt; number and if it's a =&amp;gt; character. This is the easiest way to see that.&lt;/P&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 06:46:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602541#M209742</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2022-06-21T06:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602588#M209752</link>
      <description>&lt;P&gt;but I used your query and it worked correctly:&amp;nbsp;&lt;/P&gt;&lt;P&gt;its possible that your score filed is multivalue field like my query:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|&amp;nbsp;makeresults&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;|&amp;nbsp;eval&amp;nbsp;temp="1&amp;nbsp;6.7&amp;nbsp;8&amp;nbsp;9&amp;nbsp;9.6&amp;nbsp;103&amp;nbsp;454&amp;nbsp;5&amp;nbsp;2.3&amp;nbsp;5.3&amp;nbsp;1.4"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;|&amp;nbsp;eval&amp;nbsp;score=split(temp,"&amp;nbsp;")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;|&amp;nbsp;fields&amp;nbsp;-&amp;nbsp;temp,_time&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;|&amp;nbsp;mvexpand&amp;nbsp;score&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Severity=case(score&amp;gt;=0.1 AND score&amp;lt;=3.9, "Low", score&amp;gt;=4.0 AND score&amp;lt;=6.9, "Medium", score&amp;gt;=7.0 AND score&amp;lt;=8.9, "High", score&amp;gt;=9.0 AND score&amp;lt;=10.0, "Critical", true(), "Other")&lt;/SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tempp.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20193i0120D13DFB1E71EF/image-size/large?v=v2&amp;amp;px=999" role="button" title="tempp.png" alt="tempp.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 10:51:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602588#M209752</guid>
      <dc:creator>marysan</dc:creator>
      <dc:date>2022-06-21T10:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602620#M209758</link>
      <description>&lt;P&gt;Thank you for this - I did verify that the field was a number, but I plugged in your eval anyway. Still doesn't work, though I appreciate the tip about reading from left to right (I didn't know that).&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 13:34:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602620#M209758</guid>
      <dc:creator>mistydennis</dc:creator>
      <dc:date>2022-06-21T13:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602621#M209759</link>
      <description>&lt;P&gt;That is a good tip - yes, the field is a number.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 13:34:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602621#M209759</guid>
      <dc:creator>mistydennis</dc:creator>
      <dc:date>2022-06-21T13:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602623#M209760</link>
      <description>&lt;P&gt;Yes, it does seem to work with your query but unfortunately it does not work in mine. I have confirmed the field is not multivalue.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 13:37:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602623#M209760</guid>
      <dc:creator>mistydennis</dc:creator>
      <dc:date>2022-06-21T13:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602625#M209761</link>
      <description>&lt;P&gt;I tried this as well, no luck. All values are still "Other".&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 13:40:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602625#M209761</guid>
      <dc:creator>mistydennis</dc:creator>
      <dc:date>2022-06-21T13:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602632#M209763</link>
      <description>&lt;P&gt;Solved! Thank you to everyone that provided hints - it turns out that the field in question was coming from a lookup, and for some reason I could not successfully apply the case statement in my query. But I opened up the lookup query, added the case statement there, and it worked. I don't understand why this worked, but it did.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 13:54:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602632#M209763</guid>
      <dc:creator>mistydennis</dc:creator>
      <dc:date>2022-06-21T13:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602635#M209765</link>
      <description>&lt;P&gt;One way to see what those fields contains is a create a new field like&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
| eval contains="&amp;gt;" . field . "&amp;lt;"
| ...&lt;/LI-CODE&gt;&lt;P&gt;That way it's not needed to guess what that field contains.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 14:02:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-this-case-statement/m-p/602635#M209765</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2022-06-21T14:02:35Z</dc:date>
    </item>
  </channel>
</rss>

