<?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: How to create a case statement with NOT LIKE option? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414350#M119381</link>
    <description>&lt;P&gt;Use this:&lt;/P&gt;

&lt;P&gt;| eval usage=case(like(_raw,"%FirstClass%"),"A_Grade",like(_raw,"%SecondClass%"),"B_Grade",like(_raw,"%ThirdClass%"),"C_Grade", true(), "failed")&lt;/P&gt;

&lt;P&gt;Case will take the first statement that is true, so the &lt;CODE&gt;true()&lt;/CODE&gt; will be the last-case-fallback and return "failed" for all that did not meet any other criteria before. &lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 19:36:07 GMT</pubDate>
    <dc:creator>xpac</dc:creator>
    <dc:date>2020-09-29T19:36:07Z</dc:date>
    <item>
      <title>How to create a case statement with NOT LIKE option?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414349#M119380</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| eval usage=case(like(_raw,"%FirstClass%"),"A_Grade",like(_raw,"%SecondClass%"),"B_Grade",like(_raw,"%ThirdClass%"),"C_Grade")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My question is, in the above statement when I draw a pie chart that gives me A, B, C_Grade.  However I want to know all the failed student in the chart as well.&lt;BR /&gt;
My _raw contains all the events i.e. all three grades and the failed student as well. &lt;BR /&gt;
The logic to find that is, "If the  _raw doesn't contain the string 'FirstClass' or 'SecondClass' or 'ThirdClass' , then whatever remaining in _raw is considered as 'Failed'. How do I implement this logic using case?&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 09:24:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414349#M119380</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2018-05-22T09:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a case statement with NOT LIKE option?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414350#M119381</link>
      <description>&lt;P&gt;Use this:&lt;/P&gt;

&lt;P&gt;| eval usage=case(like(_raw,"%FirstClass%"),"A_Grade",like(_raw,"%SecondClass%"),"B_Grade",like(_raw,"%ThirdClass%"),"C_Grade", true(), "failed")&lt;/P&gt;

&lt;P&gt;Case will take the first statement that is true, so the &lt;CODE&gt;true()&lt;/CODE&gt; will be the last-case-fallback and return "failed" for all that did not meet any other criteria before. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:36:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414350#M119381</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2020-09-29T19:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a case statement with NOT LIKE option?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414351#M119382</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/110013"&gt;@xpac&lt;/a&gt;. &lt;BR /&gt;
But it only returns me the events that are "failed". It won't return me A_Grade, B_Grade, C_Grade data !&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:39:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414351#M119382</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T19:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a case statement with NOT LIKE option?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414352#M119383</link>
      <description>&lt;P&gt;That approach to put a &lt;CODE&gt;true(),"failed"&lt;/CODE&gt; option at the end of the case statement is perfectly valid though. Can you post the exact code you tested with? Please post it as code (using the 101010 button).&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 14:29:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414352#M119383</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-05-22T14:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a case statement with NOT LIKE option?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414353#M119384</link>
      <description>&lt;P&gt;If that's the case, it's an issue with the rest of your query. Eval never filters anything out. &lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 14:31:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414353#M119384</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2018-05-22T14:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a case statement with NOT LIKE option?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414354#M119385</link>
      <description>&lt;P&gt;@zacksoft, you can use &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/ConditionalFunctions#searchmatch.28X.29"&gt;searchmatch()&lt;/A&gt; to find pattern in raw events (ideally you should create field extractions).&lt;BR /&gt;
As per the question you have &lt;CODE&gt;case()&lt;/CODE&gt; conditions to match A, B and C grades and everything else is supposed to be considered as Failed. So, you can use &lt;CODE&gt;true()&lt;/CODE&gt; or &lt;CODE&gt;1==1&lt;/CODE&gt; condition in the case() statement to defined unmatched events as Failed. Please try the following run anywhere search and confirm:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval data="FirstClass;SecondClass;ThirdClass;Others"
| makemv data delim=";"
| mvexpand data
| rename data as _raw
| eval usage=case(searchmatch("FirstClass"),"A_Grade",searchmatch("SecondClass"),"B_Grade",searchmatch("ThirdClass"),"C_Grade",true(),"Failed")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 May 2018 14:49:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414354#M119385</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-22T14:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a case statement with NOT LIKE option?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414355#M119386</link>
      <description>&lt;P&gt;Absolutely brilliant. Thank you very much. The solution you provided does exactly what I wanted.&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 15:04:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414355#M119386</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2018-05-22T15:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a case statement with NOT LIKE option?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414356#M119387</link>
      <description>&lt;P&gt;@zacksoft, glad it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Accept the answer to mark this question as answered!&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 15:07:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-case-statement-with-NOT-LIKE-option/m-p/414356#M119387</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-22T15:07:55Z</dc:date>
    </item>
  </channel>
</rss>

