<?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: How can I use a combination of an IF statement along with AND? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332523#M166099</link>
    <description>&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2017 14:45:51 GMT</pubDate>
    <dc:creator>HiroshiSatoh</dc:creator>
    <dc:date>2017-09-13T14:45:51Z</dc:date>
    <item>
      <title>How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332519#M166095</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;How can I use a combination of an IF statement along with AND.&lt;/P&gt;

&lt;P&gt;I'm looking to run a count whereby IF the _hour is greater than a certain time, AND a server name matches a list, dont include the server in the results.&lt;/P&gt;

&lt;P&gt;I have something like this;&lt;/P&gt;

&lt;P&gt;mysearch...&lt;BR /&gt;
| eval hour=tonumber(strftime(_time,"%H")) &lt;BR /&gt;
| if(hour&amp;gt;2 AND NOT (dest="server1" OR dest="server2" OR dest="server3"))&lt;BR /&gt;
| stats count by _time, hour, dest, status &lt;/P&gt;

&lt;P&gt;Essentially I dont want to include results of a server between certain hours.&lt;/P&gt;

&lt;P&gt;Any ideas?  Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 12:43:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332519#M166095</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2017-09-13T12:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332520#M166096</link>
      <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search) date_hour&amp;gt;2  NOT (dest="server1" OR dest="server2" OR dest="server3")
| stats count by date_hour, dest, status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;| eval hour=tonumber(strftime(_time,"%H")) &lt;BR /&gt;
↓&lt;BR /&gt;
date_hour&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:44:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332520#M166096</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2020-09-29T15:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332521#M166097</link>
      <description>&lt;P&gt;as a quick note, &lt;CODE&gt;strftime(_time,"%H")&lt;/CODE&gt;  can be different than &lt;CODE&gt;date_hour&lt;/CODE&gt; when the user is set to a different time zone than the data. &lt;CODE&gt;strftime(_time,"%H")&lt;/CODE&gt; will put the calculate the hour for the time zone the user is in and &lt;CODE&gt;date_hour&lt;/CODE&gt; will be the hour the data says. &lt;/P&gt;

&lt;P&gt;For instance. if a user is set to be in Central time and data is coming from Pacific time, &lt;CODE&gt;strftime(_time,"%H")&lt;/CODE&gt; will create a value of 4 and date_hour will have a value of 2. &lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 13:02:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332521#M166097</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-09-13T13:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332522#M166098</link>
      <description>&lt;P&gt;You are confusing two constructs...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval foo=if(bar=2,"value1",field2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...and... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where ((bar=2) AND (foo=field2))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or possibly...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search ((bar=2) AND (foo="value2"))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Remember that &lt;CODE&gt;search&lt;/CODE&gt; does not &lt;EM&gt;"dereference"&lt;/EM&gt; the value on the right of the equals sign... it assumes that the thing on the right is a literal or a constant of some sort, as opposed to a field name. &lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 13:20:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332522#M166098</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-13T13:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332523#M166099</link>
      <description>&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 14:45:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332523#M166099</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2017-09-13T14:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332524#M166100</link>
      <description>&lt;P&gt;Hey @jacqu3sy, if they solved your problem, please remember to "accept" an answer to award karma points and to close the question. You can upvote answers and comments too! All actions award karma points. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 22:34:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332524#M166100</guid>
      <dc:creator>lfedak_splunk</dc:creator>
      <dc:date>2017-09-13T22:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332525#M166101</link>
      <description>&lt;P&gt;I kind of follow, but I'm not sure how I would use this in the example I have.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 08:57:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332525#M166101</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2017-09-15T08:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332526#M166102</link>
      <description>&lt;P&gt;Sorry, but I dont follow this. surely this query would ignore anything that occurs before 2? I only want it to ignore results before 2 when it matches a specific server name.&lt;/P&gt;

&lt;P&gt;So I need to produce results ONLY if the hour is greater than 2 AND not a certain server. If the hour is less than 2 but a differant server than that listed in the query, I still need to see the results.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 08:59:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332526#M166102</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2017-09-15T08:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332527#M166103</link>
      <description>&lt;P&gt;Something like this you mean?&lt;/P&gt;

&lt;P&gt;| eval suppress=if((hour &amp;gt; 2 and hour &amp;lt; 4 AND (dest="x.x.x.x")"yes","no"))&lt;BR /&gt;
| where suppress="no"&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 09:45:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332527#M166103</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2017-09-15T09:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332528#M166104</link>
      <description>&lt;P&gt;the following worked, thanks for pointing in the right direction:&lt;/P&gt;

&lt;P&gt;| eval suppress=if((hour &amp;gt;=10 AND hour &amp;lt;=13) AND (dest="x.x.x.x"),"yes", "no")&lt;BR /&gt;
| where suppress="no"&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 10:28:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332528#M166104</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2017-09-15T10:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a combination of an IF statement along with AND?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332529#M166105</link>
      <description>&lt;P&gt;@jacqu3sy - You can do it in one step... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where NOT ((hour &amp;gt;=10 AND hour &amp;lt;=13) AND (dest="x.x.x.x"))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where hour&amp;lt;10 OR hour&amp;gt;13 OR dest!="x.x.x.x" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Sep 2017 21:16:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-combination-of-an-IF-statement-along-with-AND/m-p/332529#M166105</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-15T21:16:52Z</dc:date>
    </item>
  </channel>
</rss>

