<?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: eval command with multiple if conditions not working in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619076#M215171</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/80737"&gt;@inventsekar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Why do we need to add makeresults? Also why do we need to multiple eval commands?&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Suman P.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2022 09:37:44 GMT</pubDate>
    <dc:creator>SumanPalisetty</dc:creator>
    <dc:date>2022-11-01T09:37:44Z</dc:date>
    <item>
      <title>Why is my eval command with multiple if conditions not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619058#M215157</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have used eval with multiple if conditions and it's failing. Kindly help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;source = "2access_30DAY.log"
 | eval new_field = if(status==200, "I love you Suman", "I love you Cloeh", if(status==403, "Suman Cloeh", "Cloeh Suman"))
 | table status, new_field&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="eval3.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22254i60BC28F34B3351B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="eval3.png" alt="eval3.png" /&gt;&lt;/span&gt;Regards&lt;/P&gt;
&lt;P&gt;Suman P.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 14:43:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619058#M215157</guid>
      <dc:creator>SumanPalisetty</dc:creator>
      <dc:date>2022-11-01T14:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: eval command with multiple if conditions not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619060#M215158</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/250797"&gt;@SumanPalisetty&lt;/a&gt;&amp;nbsp;... try the Case Command..&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults |eval status="200" 
 | eval new_field = case(status==200, "I love you Suman", status==403, "I love you Cloeh",1=1,"Cloeh Suman")
 | table status, new_field&lt;/LI-CODE&gt;&lt;P&gt;its working perfect..&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="case-command.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22255iD4E7E07746EE2C31/image-size/large?v=v2&amp;amp;px=999" role="button" title="case-command.png" alt="case-command.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 07:34:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619060#M215158</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2022-11-01T07:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: eval command with multiple if conditions not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619062#M215159</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/80737"&gt;@inventsekar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I want to know what my mistake is, you all being experienced I watt to know where I am making mistake so that i will learn and never repeat it. Thank you.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Suman P.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 08:02:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619062#M215159</guid>
      <dc:creator>SumanPalisetty</dc:creator>
      <dc:date>2022-11-01T08:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: eval command with multiple if conditions not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619065#M215162</link>
      <description>&lt;P&gt;Your mistake is in the if function - you have more than 3 parameters - have another look at the documentation&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/ConditionalFunctions#if.28.26lt.3Bpredicate.26gt.3B.2C_.26lt.3Btrue_value.26gt.3B.2C_.26lt.3Bfalse_value.26gt.3B.29" target="_blank"&gt;Comparison and Conditional functions - Splunk Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 08:21:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619065#M215162</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-01T08:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: eval command with multiple if conditions not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619069#M215164</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/250797"&gt;@SumanPalisetty&lt;/a&gt;&amp;nbsp;.. the if condition format&amp;nbsp;&lt;/P&gt;&lt;P&gt;if condition is true,&lt;/P&gt;&lt;P&gt;then do this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;"do the other"&lt;/P&gt;&lt;P&gt;so, in your if condition.. if status is 200, then suman, .. or, then one more if condition..&amp;nbsp; like this one:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults |eval status="200"
 | eval new_field = if(status==200, "Suman", if(status==403, "Cloeh", "not Suman and Cloeh"))
 | table status, new_field&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="splunk-if-condition.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22256i36D0F595252BA185/image-size/large?v=v2&amp;amp;px=999" role="button" title="splunk-if-condition.png" alt="splunk-if-condition.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 08:48:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619069#M215164</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2022-11-01T08:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: eval command with multiple if conditions not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619076#M215171</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/80737"&gt;@inventsekar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Why do we need to add makeresults? Also why do we need to multiple eval commands?&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Suman P.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 09:37:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619076#M215171</guid>
      <dc:creator>SumanPalisetty</dc:creator>
      <dc:date>2022-11-01T09:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: eval command with multiple if conditions not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619132#M215186</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/250797"&gt;@SumanPalisetty&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;on your splunk environment, when you run this,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;source = "2access_30DAY.log"&lt;/PRE&gt;&lt;P&gt;splunk will get the "2access_30DAY.log" log and then the "status" will be analyzed inside the if condition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but, on my splunk environment, as i dont have the&amp;nbsp;"2access_30DAY.log" log in my system, i should create a temporary variable with eval status="200"... with this i will have a log event and then i can run the if condition.&amp;nbsp; hope you understood now.. let me know if any questions.. as the last reply was working perfectly, please accept it as a solution, so that this question will be moved to unanswered to "answered". thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 15:02:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619132#M215186</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2022-11-01T15:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my eval command with multiple if conditions not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619147#M215190</link>
      <description>&lt;P&gt;If you have multiple conditions use case not if. Much easer just ensure the last condition is 1==1,"VALUE" if you want a default when nothing before it matches.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 15:35:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-command-with-multiple-if-conditions-not-working/m-p/619147#M215190</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2022-11-01T15:35:24Z</dc:date>
    </item>
  </channel>
</rss>

