<?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 How to use NOT in an IF condition? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203486#M59116</link>
    <description>&lt;P&gt;I have 2 files: Account and Account.TXT. I have to get only the "Account" file details. I tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if(  (like(filename,"Account%") AND NOT like(filename,"Account%.txt%")  ),filename,"X")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but it is returning both file types.&lt;/P&gt;

&lt;P&gt;What is the mistake here?&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2016 20:37:28 GMT</pubDate>
    <dc:creator>prakashbhanu407</dc:creator>
    <dc:date>2016-04-14T20:37:28Z</dc:date>
    <item>
      <title>How to use NOT in an IF condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203486#M59116</link>
      <description>&lt;P&gt;I have 2 files: Account and Account.TXT. I have to get only the "Account" file details. I tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if(  (like(filename,"Account%") AND NOT like(filename,"Account%.txt%")  ),filename,"X")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but it is returning both file types.&lt;/P&gt;

&lt;P&gt;What is the mistake here?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 20:37:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203486#M59116</guid>
      <dc:creator>prakashbhanu407</dc:creator>
      <dc:date>2016-04-14T20:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use NOT in an IF condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203487#M59117</link>
      <description>&lt;P&gt;Why not just use &lt;CODE&gt;.. | if(filename="Account", x, y)&lt;/CODE&gt; and skip the wildcard altogether?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 20:52:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203487#M59117</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-04-14T20:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use NOT in an IF condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203488#M59118</link>
      <description>&lt;P&gt;actually i have 2 sets of files X and Y, &lt;BR /&gt;
X has about 10 different types of files including "AccountyyyyMMdd.hhmmss"(no extension)&lt;BR /&gt;
Y has another 8 files types including "AccountyyyyMMdd.hhmmss.TXT"&lt;/P&gt;

&lt;P&gt;So for the "X" type of files I have multiple "like()" functions in the if() condition, it should only retrieve data for  "Account" file but it is also picking up for "Account.TXT" which should be of type "Y"&lt;BR /&gt;
like below&lt;BR /&gt;
if( &lt;BR /&gt;
      (like() like () ..... (like(filename,"Account%") AND NOT like(filename,"Account%.txt%")) ),"X" , &lt;BR /&gt;
                                                                                                       if( (like() like()...like(filename,"Account%.txt%"),"Y","Other")&lt;BR /&gt;
                                                     ) &lt;BR /&gt;
    )&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 04:19:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203488#M59118</guid>
      <dc:creator>prakashbhanu407</dc:creator>
      <dc:date>2016-04-15T04:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to use NOT in an IF condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203489#M59119</link>
      <description>&lt;P&gt;Try the &lt;CODE&gt;match()&lt;/CODE&gt; with &lt;CODE&gt;regex&lt;/CODE&gt; . Something like this should work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | eval x=case(match(filename, "Account\d+\.\d+$", "no extn", filename="\.(txt|TXT)$", "with extn", 1=1, "no match")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Apr 2016 16:14:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203489#M59119</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-04-15T16:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to use NOT in an IF condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203490#M59120</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval test = if((like(filename, "Account") AND NOT like(filename, "Account%.txt")), filename," X")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your problem is the wildcard character &lt;CODE&gt;%&lt;/CODE&gt;, most of which you do not need.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 13:46:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-NOT-in-an-IF-condition/m-p/203490#M59120</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-26T13:46:28Z</dc:date>
    </item>
  </channel>
</rss>

