<?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 my eval case statement? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425142#M121909</link>
    <description>&lt;P&gt;Now that we have fixed the syntax errors, I think this would be better being replaced with this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=foo 
 | eval Count=if(((sourcetype="input1" OR sourcetype="input2") AND index="foo1")
     OR ((sourcetype="input3" OR sourcetype="input4" OR sourcetype="input5" OR sourcetype="input6" OR sourcetype="input7") AND index="foo2")
     OR ((sourcetype="input8" OR sourcetype="input9" OR sourcetype="input10" OR sourcetype="input11") AND index="foo3"), "NA", Count)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 07 Mar 2019 18:05:01 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-03-07T18:05:01Z</dc:date>
    <item>
      <title>What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425131#M121898</link>
      <description>&lt;P&gt;What is wrong with this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Count=case((sourcetype="input1" OR sourcetype="input2") AND index="foo1", "NA" 
(sourcetype="input3" OR sourcetype="input4" OR sourcetype="input5" OR sourcetype="input6" OR 
sourcetype="input7") AND index="foo2", "NA"
(sourcetype=”input8” OR sourcetype="input9" OR sourcetype="input10" OR sourcetype=”input11”) AND index=”foo3”, "NA", true(),"Count"))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Mar 2019 06:46:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425131#M121898</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-03-07T06:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425132#M121899</link>
      <description>&lt;P&gt;Error in 'eval' command: The expression is malformed. Expected ).&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 06:51:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425132#M121899</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-03-07T06:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425133#M121900</link>
      <description>&lt;P&gt;The structure of case is &lt;/P&gt;

&lt;P&gt;Case (condition,value if  success, 1=1, value if none of the condition success)&lt;/P&gt;

&lt;P&gt;Please try the below code,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  makeresults 
|  eval sourcetype="input8", index="foo3"
|  eval Count=case(((sourcetype="input1" OR sourcetype="input2") AND index="foo1"), "true" ,
((sourcetype="input3" OR sourcetype="input4" OR sourcetype="input5" OR sourcetype="input6" OR 
sourcetype="input7") AND index="foo2"), "true",
((sourcetype="input8" OR sourcetype="input9" OR sourcetype="input10" OR sourcetype="input11") AND index="foo3"), "true",1=1,"Count")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Mar 2019 07:00:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425133#M121900</guid>
      <dc:creator>sdchakraborty</dc:creator>
      <dc:date>2019-03-07T07:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425134#M121901</link>
      <description>&lt;P&gt;@ryhluc01 you are missing couple of commas with first two case conditions. You also have an extra close bracket. Finally be cautious with quotes characters UTF-8 quotes characters are only accepted in SPL. Try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Count=case((sourcetype="input1" OR sourcetype="input2") AND index="foo1", "NA", 
    (sourcetype="input3" OR sourcetype="input4" OR sourcetype="input5" OR sourcetype="input6" OR sourcetype="input7") AND index="foo2", "NA",
    (sourcetype="input8" OR sourcetype="input9" OR sourcetype="input10" OR sourcetype="input11") AND index="foo3", "NA",
    true(),"Count")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Mar 2019 08:00:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425134#M121901</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-03-07T08:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425135#M121902</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo 
| eval Count=case((sourcetype="input1" OR sourcetype="input2") AND index="foo1", "NA",
(sourcetype="input3" OR sourcetype="input4" OR sourcetype="input5" OR sourcetype="input6" OR sourcetype="input7") AND index="foo2", "NA",
(sourcetype="input8" OR sourcetype="input9" OR sourcetype="input10" OR sourcetype="input11") AND index="foo3", "NA", 
true(), Count)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You were missing 2 commas, had an extra &lt;CODE&gt;)&lt;/CODE&gt; on the end and had microsoft/paired/handed double-quotes instead of the splunk ones.  Cut and paste my answer above.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 13:03:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425135#M121902</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-07T13:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425136#M121903</link>
      <description>&lt;P&gt;That last ) is redundant &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 13:08:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425136#M121903</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-03-07T13:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425137#M121904</link>
      <description>&lt;P&gt;true() can be used just as well and why are you replacing his "NA" by "true"? Also, no need to put () around each entire logical expression.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 13:11:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425137#M121904</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-03-07T13:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425138#M121905</link>
      <description>&lt;P&gt;Thank you, yes.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 16:12:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425138#M121905</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-07T16:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425139#M121906</link>
      <description>&lt;P&gt;@ryhluc01 if your issue is resolved, do accept the answer to mark this question as answered.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 17:38:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425139#M121906</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-03-07T17:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425140#M121907</link>
      <description>&lt;P&gt;Hey Everyone, &lt;/P&gt;

&lt;P&gt;So the corrections from @niketnilay  &amp;amp; @woodcock  were perfect. &lt;/P&gt;

&lt;P&gt;Is there anyway to keep my original values for everything else that does not meet the case conditions? That is what I was trying to achieve with the count @ the end of the syntax. &lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 17:50:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425140#M121907</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-03-07T17:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425141#M121908</link>
      <description>&lt;P&gt;Somebody mistook me (@woodcock) for @somesoni2! &lt;span class="lia-unicode-emoji" title=":grinning_squinting_face:"&gt;😆&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 18:00:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425141#M121908</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-07T18:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425142#M121909</link>
      <description>&lt;P&gt;Now that we have fixed the syntax errors, I think this would be better being replaced with this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=foo 
 | eval Count=if(((sourcetype="input1" OR sourcetype="input2") AND index="foo1")
     OR ((sourcetype="input3" OR sourcetype="input4" OR sourcetype="input5" OR sourcetype="input6" OR sourcetype="input7") AND index="foo2")
     OR ((sourcetype="input8" OR sourcetype="input9" OR sourcetype="input10" OR sourcetype="input11") AND index="foo3"), "NA", Count)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Mar 2019 18:05:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425142#M121909</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-07T18:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425143#M121910</link>
      <description>&lt;P&gt;I edited my original answer.  You also were using &lt;CODE&gt;"Count"&lt;/CODE&gt; which is a &lt;CODE&gt;string-literal&lt;/CODE&gt; instead of &lt;CODE&gt;Count&lt;/CODE&gt; which is a field name.  I assume that you meant the latter.  Also, see my other answer.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 18:06:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425143#M121910</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-07T18:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425144#M121911</link>
      <description>&lt;P&gt;@woodcock Thank you and you're right! How did I do that &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;BR /&gt;
Its fixed. I think I just comb through so many forum posts a day lol. &lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 19:55:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425144#M121911</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-03-07T19:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425145#M121912</link>
      <description>&lt;P&gt;I'll give this a shot...one moment. &lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 19:58:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425145#M121912</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-03-07T19:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my eval case statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425146#M121913</link>
      <description>&lt;P&gt;Thanks Everyone! &lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 21:18:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-s-wrong-with-my-eval-case-statement/m-p/425146#M121913</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-03-07T21:18:10Z</dc:date>
    </item>
  </channel>
</rss>

