<?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: If Statment or Nested If in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/516512#M145176</link>
    <description>&lt;P&gt;HI! It seems like you might see where i am having trouble with the if statement. Thank you in advance!&lt;/P&gt;&lt;P&gt;I have a field called Status, and once of the values is called Queue. I want to replace the word Queue with either Risk or Missed - that is dependent on another field called Dep. So if&amp;nbsp; Dep=Risk, then the Queue value should be renamed Risk, and if Dep=Missed, then Queue value should be renamed as Missed. Here is my search:&lt;/P&gt;&lt;P&gt;| eval Status = if(Status="Queue", (case(Dep="RISK", RISK), (Dep="MISSED", MISSED)))&lt;/P&gt;</description>
    <pubDate>Thu, 27 Aug 2020 13:20:45 GMT</pubDate>
    <dc:creator>yvassilyeva</dc:creator>
    <dc:date>2020-08-27T13:20:45Z</dc:date>
    <item>
      <title>If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30586#M6214</link>
      <description>&lt;P&gt;This statement works:&lt;BR /&gt;
 | &lt;STRONG&gt;eval Reason = if (Failure_Code = "0x12", "Account disabled, expired, locked out, logon hours","Don't_Know")&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;But how to I evaluate it so that reason can be something different for different codes.&lt;BR /&gt;&lt;BR /&gt;
I tried this and it did not work:&lt;BR /&gt;
| &lt;STRONG&gt;eval Reason = if (Failure_Code = "0x18", "Usually means bad password","(if (Failure_Code = "0x12", "Account disabled, expired, locked out, logon hours","Don't_Know")")&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;Is there any way to use "&lt;STRONG&gt;OR&lt;/STRONG&gt;" maybe nesting the "&lt;STRONG&gt;if&lt;/STRONG&gt;" in the &lt;STRONG&gt;not true&lt;/STRONG&gt; section like I did above maybe several eval statements but that didn’t work either.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:41:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30586#M6214</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2020-09-28T09:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30587#M6215</link>
      <description>&lt;P&gt;You want &lt;CODE&gt;case&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Reason = case(Failure_Code = "0x18", "Usually means bad password",Failure_Code = "0x12", "Account disabled, expired, locked out, logon hours")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;case&lt;/CODE&gt; does not by itself have a finishing default value if all of the previous statements are false, but as all statements are processed sequentially and the first matching one will be returned, you can easily finish off with a default value simply by putting in a statement you know to be true:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Reason = case(Failure_Code = "0x18", "Usually means bad password",Failure_Code = "0x12", "Account disabled, expired, locked out, logon hours", 1=1, "Don't know")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Jun 2011 16:46:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30587#M6215</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2011-06-17T16:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30588#M6216</link>
      <description>&lt;P&gt;Thanks Ayn&lt;/P&gt;

&lt;P&gt;I tried this case statment:&lt;BR /&gt;
| eval Reason = case(Failure_Code == 0x18, "Usually means bad password",Failure_Code == 0x12, "Account disabled, expired, locked out, logon hours","Don't_Know") &lt;/P&gt;

&lt;P&gt;but I most have the syntax wrong as it did not work.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:41:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30588#M6216</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2020-09-28T09:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30589#M6217</link>
      <description>&lt;P&gt;You forgot to put a statement to evaluate before "Don't_Know". Put something like 1=1 in there and it should work.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2011 17:31:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30589#M6217</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2011-06-17T17:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30590#M6218</link>
      <description>&lt;P&gt;I put "" around the error code number "0x18" and it worked.  thanks for the help this fixes it for me.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2011 17:31:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30590#M6218</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2011-06-17T17:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30591#M6219</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;case does not by itself have a finishing default value if all of the previous statements are false, but as all statements are processed sequentially and the first matching one will be returned, you can easily finish off with a default value simply by putting in a statement you know to be true:&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Alternatively one can use the coalesce function:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Reason = coalesce( case(Failure_Code = "0x18", "Usually means bad password",Failure_Code = "0x12", "Account disabled, expired, locked out, logon hours"), "Don't know")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2012 12:31:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30591#M6219</guid>
      <dc:creator>Skeeve</dc:creator>
      <dc:date>2012-02-22T12:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30592#M6220</link>
      <description>&lt;P&gt;thanks this is a great addon to the case statment for when the value is not known&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2012 14:18:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30592#M6220</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2012-02-22T14:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30593#M6221</link>
      <description>&lt;P&gt;You may use multiple IF statements in the same eval, just remember to close them all.&lt;/P&gt;

&lt;P&gt;For example:&lt;BR /&gt;
| eval StartNum = if (&lt;BR /&gt;
substr(TwitterID,1,1) = "0", 0,&lt;BR /&gt;
if(substr(TwitterID,1,1) = "1", 1,&lt;BR /&gt;
if(substr(TwitterID,1,1) = "2", 2,&lt;BR /&gt;
if(substr(TwitterID,1,1) = "3", 3,&lt;BR /&gt;
"over 3"&lt;BR /&gt;
))))&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 12:52:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30593#M6221</guid>
      <dc:creator>rbrownlee</dc:creator>
      <dc:date>2014-04-08T12:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30594#M6222</link>
      <description>&lt;P&gt;Ayn...you are such an amazing help!!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Apr 2014 12:18:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30594#M6222</guid>
      <dc:creator>ECovell</dc:creator>
      <dc:date>2014-04-15T12:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30595#M6223</link>
      <description>&lt;P&gt;simply .......&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2015 20:20:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30595#M6223</guid>
      <dc:creator>stephane_cyrill</dc:creator>
      <dc:date>2015-04-26T20:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30596#M6224</link>
      <description>&lt;P&gt;Thanks, that got it for me.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2015 18:45:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30596#M6224</guid>
      <dc:creator>rfiscus</dc:creator>
      <dc:date>2015-11-02T18:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30597#M6225</link>
      <description>&lt;P&gt;Thanks a lot!! It helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2016 12:28:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30597#M6225</guid>
      <dc:creator>bagarwal</dc:creator>
      <dc:date>2016-05-31T12:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30598#M6226</link>
      <description>&lt;P&gt;Thank you for answering the nested if statement question instead of proposing a case statement.  The colorPalette expression option does not appear to like case statements.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.1.2/Viz/TableFormatsXML"&gt;https://docs.splunk.com/Documentation/Splunk/7.1.2/Viz/TableFormatsXML&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;However, your nested if option worked great.  For example:      &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;colorPalette type="expression"&amp;gt;if(value LIKE "Server 2003", "#00cc00", if(value LIKE "Windows 10","#00cc00","#D93F3C"))&amp;lt;/colorPalette&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 Aug 2018 17:46:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30598#M6226</guid>
      <dc:creator>TonyLeeVT</dc:creator>
      <dc:date>2018-08-04T17:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30599#M6227</link>
      <description>&lt;P&gt;@TonyLeeVT thanks for sharing this hidden nugget! I thought Simple XML JS extesion was the only way for this scenario &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Aug 2018 18:27:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/30599#M6227</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-04T18:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: If Statment or Nested If</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/516512#M145176</link>
      <description>&lt;P&gt;HI! It seems like you might see where i am having trouble with the if statement. Thank you in advance!&lt;/P&gt;&lt;P&gt;I have a field called Status, and once of the values is called Queue. I want to replace the word Queue with either Risk or Missed - that is dependent on another field called Dep. So if&amp;nbsp; Dep=Risk, then the Queue value should be renamed Risk, and if Dep=Missed, then Queue value should be renamed as Missed. Here is my search:&lt;/P&gt;&lt;P&gt;| eval Status = if(Status="Queue", (case(Dep="RISK", RISK), (Dep="MISSED", MISSED)))&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 13:20:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statment-or-Nested-If/m-p/516512#M145176</guid>
      <dc:creator>yvassilyeva</dc:creator>
      <dc:date>2020-08-27T13:20:45Z</dc:date>
    </item>
  </channel>
</rss>

