<?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: AND OR not working correctly in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289632#M87627</link>
    <description>&lt;P&gt;Hey &lt;/P&gt;

&lt;P&gt;Try this !&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval Action=if(((MonitoringStatus="Not Monitored") AND (like(Path,"%Hosting%")) AND Location="Varonis" OR  '7DayBackUpStatus'="Not Backed Up"), "Action Required", "No Action Required")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps you !&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jan 2018 20:13:36 GMT</pubDate>
    <dc:creator>mayurr98</dc:creator>
    <dc:date>2018-01-05T20:13:36Z</dc:date>
    <item>
      <title>AND OR not working correctly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289629#M87624</link>
      <description>&lt;P&gt;I am getting the below error when trying to form an AND &amp;amp; OR in my query. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Error in 'eval' command: The expression is malformed. Expected ).&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;My eval is below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Action=if((MonitoringStatus="Not Monitored") AND(like(Path,"%Hosting%") 
 AND Location="Varonis" 
 OR(7DayBackUpStatus="Not Backed Up") "Action Required","No Action Required") 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 19:48:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289629#M87624</guid>
      <dc:creator>davidcraven02</dc:creator>
      <dc:date>2018-01-05T19:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: AND OR not working correctly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289630#M87625</link>
      <description>&lt;P&gt;Try this (you're missing a closing braces on conditions and command before &lt;CODE&gt;"Action Required"&lt;/CODE&gt;)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Action=if((MonitoringStatus="Not Monitored") AND 
( like(Path,"%Hosting%")  AND Location="Varonis" OR (7DayBackUpStatus="Not Backed Up")),  "Action Required","No Action Required") 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 19:58:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289630#M87625</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-05T19:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: AND OR not working correctly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289631#M87626</link>
      <description>&lt;P&gt;The field name that starts with the number &lt;CODE&gt;7&lt;/CODE&gt; needs to be in single quotes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Action=if(
    (MonitoringStatus="Not Monitored")
    AND (
        like(Path,"%Hosting%")
        AND Location="Varonis" 
        OR  '7DayBackUpStatus'="Not Backed Up"
    ), "Action Required", "No Action Required")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I suggest putting parentheses when you mix AND and OR.  I'm not sure what your intent might be, but you may consider one of these variants:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Action=if(
    (MonitoringStatus="Not Monitored")
    AND (
        (like(Path,"%Hosting%") AND Location="Varonis")
        OR  '7DayBackUpStatus'="Not Backed Up"
    ), "Action Required", "No Action Required")

| eval Action=if(
    (MonitoringStatus="Not Monitored")
    AND (
        like(Path,"%Hosting%")
        AND (Location="Varonis" OR '7DayBackUpStatus'="Not Backed Up")
    ), "Action Required", "No Action Required")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 19:59:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289631#M87626</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-05T19:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: AND OR not working correctly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289632#M87627</link>
      <description>&lt;P&gt;Hey &lt;/P&gt;

&lt;P&gt;Try this !&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval Action=if(((MonitoringStatus="Not Monitored") AND (like(Path,"%Hosting%")) AND Location="Varonis" OR  '7DayBackUpStatus'="Not Backed Up"), "Action Required", "No Action Required")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps you !&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 20:13:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289632#M87627</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-05T20:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: AND OR not working correctly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289633#M87628</link>
      <description>&lt;P&gt;Sorry I marked this accepted prematurely. it doesn't seem the OR statement is kicking in as there are more than 50 rows of data that are listed as 'Not Backed Up'&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 20:39:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289633#M87628</guid>
      <dc:creator>davidcraven02</dc:creator>
      <dc:date>2018-01-05T20:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: AND OR not working correctly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289634#M87629</link>
      <description>&lt;P&gt;I do not know how to deal with fieldname starting with a number i may be wrong &lt;BR /&gt;
Can you change the fieldname to sevendaybackupstatus&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval Action=if(((MonitoringStatus="Not Monitored") AND (like(Path,"%Hosting%")) AND Location="Varonis" OR  sevendaybackupstatus="Not Backed Up"), "Action Required", "No Action Required")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR &lt;/P&gt;

&lt;P&gt;Try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rename “7DayBackUpStatus” as sevendaybackupstatus | eval Action=if(((MonitoringStatus="Not Monitored") AND (like(Path,"%Hosting%")) AND Location="Varonis" OR  sevendaybackupstatus="Not Backed Up"), "Action Required", "No Action Required")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 20:49:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289634#M87629</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-05T20:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: AND OR not working correctly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289635#M87630</link>
      <description>&lt;P&gt;I've updated my answer to also take into consideration two alternate searches (grouped AND/OR with parentheses to make it more clear) that may correct your logic issue as well.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 20:51:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/AND-OR-not-working-correctly/m-p/289635#M87630</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-05T20:51:42Z</dc:date>
    </item>
  </channel>
</rss>

