<?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 evaluate multiple values to a single answer . Like if value in(1,5,3,2,7)  then Code1 else if value in(4,6,0) Code 2 else Code 3 in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-multiple-values-to-a-single-answer-Like-if-value/m-p/319633#M95556</link>
    <description>&lt;P&gt;I didn't know about the &lt;CODE&gt;in&lt;/CODE&gt; function!  I knew about new &lt;CODE&gt;IN&lt;/CODE&gt; operator in SPL, but not in terms of &lt;CODE&gt;eval&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jan 2018 21:38:15 GMT</pubDate>
    <dc:creator>micahkemp</dc:creator>
    <dc:date>2018-01-19T21:38:15Z</dc:date>
    <item>
      <title>How to evaluate multiple values to a single answer . Like if value in(1,5,3,2,7)  then Code1 else if value in(4,6,0) Code 2 else Code 3</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-multiple-values-to-a-single-answer-Like-if-value/m-p/319630#M95553</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I need to creating grouping of a results by error code .&lt;BR /&gt;
There are different type of error code like  1123, 0123, 0000, 1234 etc which are specific to my application.&lt;BR /&gt;
The error codes are categorized in 4 category : infra error, customer error, application error, Information_code_not_error&lt;/P&gt;

&lt;P&gt;One way is to upload a lookup file and use that but I dont have access to do that, only access I have is to run normal queries.&lt;BR /&gt;
Please help me if you know a way to do so &lt;/P&gt;

&lt;P&gt;Like if value in(1,5,3,2,7)  then Code1 else if value in(4,6,0) Code 2 else Code 3&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:44:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-multiple-values-to-a-single-answer-Like-if-value/m-p/319630#M95553</guid>
      <dc:creator>jagdeepgupta813</dc:creator>
      <dc:date>2020-09-29T17:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to evaluate multiple values to a single answer . Like if value in(1,5,3,2,7)  then Code1 else if value in(4,6,0) Code 2 else Code 3</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-multiple-values-to-a-single-answer-Like-if-value/m-p/319631#M95554</link>
      <description>&lt;P&gt;You can use case statement to do so.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search with field error_code
| eval category=case(match(error_code,"(1|5|3|2|7)"),"infra error",match(error_code,"(4|6|0)","customer error",...other conditions..., true(),"default value here")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jan 2018 17:39:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-multiple-values-to-a-single-answer-Like-if-value/m-p/319631#M95554</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-18T17:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to evaluate multiple values to a single answer . Like if value in(1,5,3,2,7)  then Code1 else if value in(4,6,0) Code 2 else Code 3</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-multiple-values-to-a-single-answer-Like-if-value/m-p/319632#M95555</link>
      <description>&lt;P&gt;You're right on track. Using the example you gave at the end of your post, I'd code it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your base search&amp;gt;
| eval code_field=case(in(val_field, "1", "5", "3", "2", "7"), "Code1", in(val_field, "4", "6", "0"), "Code2", 1=1, "Code3")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Read in plain English, this code says: &lt;EM&gt;If the value in the field &lt;CODE&gt;val_field&lt;/CODE&gt; is one, 5, 3, 2, or 7, then set the value of &lt;CODE&gt;code_field&lt;/CODE&gt; to &lt;CODE&gt;"Code1"&lt;/CODE&gt;. If the value in the field &lt;CODE&gt;val_field&lt;/CODE&gt; is 4, 6, or 0, then sent the value of &lt;CODE&gt;code_field&lt;/CODE&gt; to &lt;CODE&gt;"Code2"&lt;/CODE&gt;. Otherwise, set the value of the field &lt;CODE&gt;val_field&lt;/CODE&gt; to &lt;CODE&gt;"Code3"&lt;/CODE&gt;.&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;More info about the &lt;CODE&gt;in()&lt;/CODE&gt; function is here:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/ConditionalFunctions#in.28VALUE-LIST.29"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/ConditionalFunctions#in.28VALUE-LIST.29&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2018 17:46:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-multiple-values-to-a-single-answer-Like-if-value/m-p/319632#M95555</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-01-18T17:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to evaluate multiple values to a single answer . Like if value in(1,5,3,2,7)  then Code1 else if value in(4,6,0) Code 2 else Code 3</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-multiple-values-to-a-single-answer-Like-if-value/m-p/319633#M95556</link>
      <description>&lt;P&gt;I didn't know about the &lt;CODE&gt;in&lt;/CODE&gt; function!  I knew about new &lt;CODE&gt;IN&lt;/CODE&gt; operator in SPL, but not in terms of &lt;CODE&gt;eval&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 21:38:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-multiple-values-to-a-single-answer-Like-if-value/m-p/319633#M95556</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-19T21:38:15Z</dc:date>
    </item>
  </channel>
</rss>

