<?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: nested case  statements with eval in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-nested-case-statements-with-eval/m-p/590576#M205614</link>
    <description>&lt;P&gt;Try putting the field names with hyphens in in single quotes - something like this (or use fieldnames without hyphens!)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;table hqid, httpStatus | eval status-success=if(httpStatus="200",1,0) | eval status-fail= if(httpStatus != "200",1,0)
| stats sum(status-success) as status-success, sum(status-fail) as status-fail by hqid | eval status = case('status-fail' = 0 AND 'status-success' &amp;gt; 0, "successful-logins", 'status-fail' &amp;gt; 0 AND 'status-success' &amp;gt; 0, "multi-success", 'status-fail' &amp;gt; 0 AND 'status-success'=0, "multi-fail", 'status-fail' &amp;gt; 0, "fail",1=1,"Others")&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 24 Mar 2022 06:43:04 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-03-24T06:43:04Z</dc:date>
    <item>
      <title>How to compare nested case statements with eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-nested-case-statements-with-eval/m-p/590562#M205606</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am trying to use &lt;STRONG&gt;case&lt;/STRONG&gt; keyword to solve a multiple nested statement &amp;nbsp;but it is just giving me output for the else value, it seems like it is not going inside any other statement to check, Could anyone please help me here. I tired using multiple if statement with eval still I was having the same issue.&lt;/P&gt;
&lt;P&gt;Problem statement : I want to compare the value of status-fail and status-success and on the basis of that we need to generate the output&lt;/P&gt;
&lt;P&gt;case1 : if value of status-fail =0 and status-success&amp;gt;0 ---&amp;gt; successful logins&lt;/P&gt;
&lt;P&gt;case2:&amp;nbsp;if value of status-fail &amp;gt;0 and status-success&amp;gt;0 ---&amp;gt; &amp;nbsp;multi-successful logins&lt;/P&gt;
&lt;P&gt;case3:&amp;nbsp;if value of status-fail &amp;gt;0 and status-success=0 ---&amp;gt; multi-fail&lt;/P&gt;
&lt;P&gt;case4:&amp;nbsp;if value of status-fail &amp;gt;0 &amp;nbsp;---&amp;gt; fail logins&lt;/P&gt;
&lt;P&gt;Below is the query what I am using :&lt;/P&gt;
&lt;P&gt;table hqid, httpStatus | eval status-success=if(httpStatus="200",1,0) | eval status-fail= if(httpStatus != "200",1,0)&lt;BR /&gt;| stats sum(status-success) as status-success, sum(status-fail) as status-fail by hqid | eval status = case(status-fail = 0 AND status-success &amp;gt; 0, "successful-logins", status-fail &amp;gt; 0 AND status-success &amp;gt; 0, "multi-success", status-fail &amp;gt; 0 AND status-success=0, "multi-fail", status-fail &amp;gt; 0, "fail",1=1,"Others")&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 15:14:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-nested-case-statements-with-eval/m-p/590562#M205606</guid>
      <dc:creator>anu1729</dc:creator>
      <dc:date>2022-03-24T15:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: nested case  statements with eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-nested-case-statements-with-eval/m-p/590576#M205614</link>
      <description>&lt;P&gt;Try putting the field names with hyphens in in single quotes - something like this (or use fieldnames without hyphens!)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;table hqid, httpStatus | eval status-success=if(httpStatus="200",1,0) | eval status-fail= if(httpStatus != "200",1,0)
| stats sum(status-success) as status-success, sum(status-fail) as status-fail by hqid | eval status = case('status-fail' = 0 AND 'status-success' &amp;gt; 0, "successful-logins", 'status-fail' &amp;gt; 0 AND 'status-success' &amp;gt; 0, "multi-success", 'status-fail' &amp;gt; 0 AND 'status-success'=0, "multi-fail", 'status-fail' &amp;gt; 0, "fail",1=1,"Others")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 24 Mar 2022 06:43:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-nested-case-statements-with-eval/m-p/590576#M205614</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-03-24T06:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: nested case  statements with eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-nested-case-statements-with-eval/m-p/590584#M205620</link>
      <description>&lt;P&gt;Thank you , its working now.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 07:01:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-nested-case-statements-with-eval/m-p/590584#M205620</guid>
      <dc:creator>anu1729</dc:creator>
      <dc:date>2022-03-24T07:01:31Z</dc:date>
    </item>
  </channel>
</rss>

