<?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 Using like() in a case statement not working in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-like-in-a-case-statement-not-working/m-p/91072#M23435</link>
    <description>&lt;P&gt;Hey everyone. I am working with telephone records, and am trying to work around Splunk's inability to search for literal asterisks(*). To work around I am using a regex to select only records starting with * or #, and then I am trying to use a case statement in eval to figure out what type of feature is being used by our customer.&lt;/P&gt;

&lt;P&gt;Example values of MYSOURCEFIELD (not exhaustive): *67, #31, *82&lt;/P&gt;

&lt;P&gt;Here is the search currently, it only searches for the first 2 cases:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MYSOURCE|regex MYSOURCEFIELD="(\*|#)(31|67|82|65|77|87)"|eval Feature_Code=case(like(MYSOURCEFIELD,"%31"),"Caller ID Blocking Per Line",like(MYSOURCEFIELD,"%67"),"Caller ID Blocking Per Call")|table Feature_Code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This returns nothing, even though I know a significant number of both are being utilized and can even be seen without the eval/case statement. Any suggestions on how to make the case statement work would be really appreciated, thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Mar 2012 19:14:48 GMT</pubDate>
    <dc:creator>msarro</dc:creator>
    <dc:date>2012-03-13T19:14:48Z</dc:date>
    <item>
      <title>Using like() in a case statement not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-like-in-a-case-statement-not-working/m-p/91072#M23435</link>
      <description>&lt;P&gt;Hey everyone. I am working with telephone records, and am trying to work around Splunk's inability to search for literal asterisks(*). To work around I am using a regex to select only records starting with * or #, and then I am trying to use a case statement in eval to figure out what type of feature is being used by our customer.&lt;/P&gt;

&lt;P&gt;Example values of MYSOURCEFIELD (not exhaustive): *67, #31, *82&lt;/P&gt;

&lt;P&gt;Here is the search currently, it only searches for the first 2 cases:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MYSOURCE|regex MYSOURCEFIELD="(\*|#)(31|67|82|65|77|87)"|eval Feature_Code=case(like(MYSOURCEFIELD,"%31"),"Caller ID Blocking Per Line",like(MYSOURCEFIELD,"%67"),"Caller ID Blocking Per Call")|table Feature_Code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This returns nothing, even though I know a significant number of both are being utilized and can even be seen without the eval/case statement. Any suggestions on how to make the case statement work would be really appreciated, thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2012 19:14:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-like-in-a-case-statement-not-working/m-p/91072#M23435</guid>
      <dc:creator>msarro</dc:creator>
      <dc:date>2012-03-13T19:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using like() in a case statement not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-like-in-a-case-statement-not-working/m-p/91073#M23436</link>
      <description>&lt;P&gt;Were you able to do this in steps, first evaluating your data -&lt;BR /&gt;
index = my_source - did return some events,&lt;BR /&gt;
index = my_source | regex my_source_field="(*|#)(31|67|82|65|77|87)" - did populate the field my_source_field,&lt;BR /&gt;
then if that is the case, try adding the following&lt;BR /&gt;
| eval feature_code = case(my_source_field like "%31%","Caller ID Blocking Per Line",my_source_field like "%67%","Caller ID Blocking Per Call") | table feature_code&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:34:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-like-in-a-case-statement-not-working/m-p/91073#M23436</guid>
      <dc:creator>schava</dc:creator>
      <dc:date>2020-09-28T11:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using like() in a case statement not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-like-in-a-case-statement-not-working/m-p/91074#M23437</link>
      <description>&lt;P&gt;Your example definitely helped me get case working with like.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Apr 2018 13:00:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-like-in-a-case-statement-not-working/m-p/91074#M23437</guid>
      <dc:creator>Nextbeat</dc:creator>
      <dc:date>2018-04-06T13:00:11Z</dc:date>
    </item>
  </channel>
</rss>

