<?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 Multiple Where Claus in the same search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76796#M19418</link>
    <description>&lt;P&gt;I have a search like this&lt;/P&gt;

&lt;P&gt;sourcetype=foo-bar category=foo | stats count by category | where count&amp;gt;5&lt;/P&gt;

&lt;P&gt;I have 5 category's that show in the table with a count, when count is more than 5&lt;/P&gt;

&lt;P&gt;I would like to run the same search with multiple thresholds for each category line this&lt;/P&gt;

&lt;P&gt;sourcetype=foo-bar category=foo | stats count by category | where count(category=1)&amp;gt;5 | Where count(category=2)&amp;gt;10 | Where count(category=3)&amp;gt;15 etc.&lt;/P&gt;

&lt;P&gt;Anyone know how to do this without making 5 different searches&lt;/P&gt;</description>
    <pubDate>Wed, 27 Mar 2013 18:18:42 GMT</pubDate>
    <dc:creator>hartfoml</dc:creator>
    <dc:date>2013-03-27T18:18:42Z</dc:date>
    <item>
      <title>Multiple Where Claus in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76796#M19418</link>
      <description>&lt;P&gt;I have a search like this&lt;/P&gt;

&lt;P&gt;sourcetype=foo-bar category=foo | stats count by category | where count&amp;gt;5&lt;/P&gt;

&lt;P&gt;I have 5 category's that show in the table with a count, when count is more than 5&lt;/P&gt;

&lt;P&gt;I would like to run the same search with multiple thresholds for each category line this&lt;/P&gt;

&lt;P&gt;sourcetype=foo-bar category=foo | stats count by category | where count(category=1)&amp;gt;5 | Where count(category=2)&amp;gt;10 | Where count(category=3)&amp;gt;15 etc.&lt;/P&gt;

&lt;P&gt;Anyone know how to do this without making 5 different searches&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2013 18:18:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76796#M19418</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2013-03-27T18:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Where Claus in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76797#M19419</link>
      <description>&lt;P&gt;Use the logical operators (AND OR NOT etc, note that they have to be capitalized). Also stats commands are allow to have a where clause, so you could:&lt;/P&gt;

&lt;P&gt;sourcetype=foo-bar category=foo | stats count by category where count(category=1)&amp;gt;5 OR count(category=2)&amp;gt;10 OR count(category=3)&amp;gt;15&lt;/P&gt;

&lt;P&gt;EDIT: this isn't entirely true, splunk's parser (into the prefix-notation it uses internally) can't handle this for whatever reason. Instead you need to make the operators explicitally binary, that is,&lt;/P&gt;

&lt;P&gt;sourcetype=foo-bar category=foo | stats count by category where (count(category=1)&amp;gt;5 OR count(category=2)&amp;gt;10) OR count(category=3)&amp;gt;15&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2013 18:35:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76797#M19419</guid>
      <dc:creator>tiberious726</dc:creator>
      <dc:date>2013-03-27T18:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Where Claus in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76798#M19420</link>
      <description>&lt;P&gt;Sorry this didn't seem to work&lt;/P&gt;

&lt;P&gt;I get this error "Error in 'stats' command: Repeated group-by field 'OR'" when I try the OR operator with the stats command&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2013 19:28:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76798#M19420</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2013-03-27T19:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Where Claus in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76799#M19421</link>
      <description>&lt;P&gt;copy and paste the actual search sting you are using. This works fine for me, and the error message you posted looks like you tried to put two 'OR's in a row (like "... OR OR ...") which will not work.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2013 22:40:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76799#M19421</guid>
      <dc:creator>tiberious726</dc:creator>
      <dc:date>2013-03-27T22:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Where Claus in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76800#M19422</link>
      <description>&lt;P&gt;LOL, I take that back, apparently splunk's parser is much more stupid than I gave it credit for, x OR y OR z will not work in a where clause, however (x OR y) OR z will indeed work, just use parens to make your operators explicitly binary.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2013 22:43:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76800#M19422</guid>
      <dc:creator>tiberious726</dc:creator>
      <dc:date>2013-03-27T22:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Where Claus in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76801#M19423</link>
      <description>&lt;P&gt;Sorry this didn't work either. I must be doing something wrong???&lt;/P&gt;

&lt;P&gt;When I run this search:[sourcetype="foo-bar" category="foo" | stats count by dst ]&lt;/P&gt;

&lt;P&gt;I get a table with 3 IP's and a count for each IP all with a count higher than 3&lt;/P&gt;

&lt;P&gt;When I run the same search like this [ sourcetype="foo-bar" category="foo" | stats count by dst Where (count(dst=x.x.x.1)&amp;gt;0 OR count(dst=x.x.x.2)&amp;gt;0 OR count(dst=x.x.x.3)&amp;gt;0) ]&lt;/P&gt;

&lt;P&gt;I get no results from this search. If I change the OR to AND I still get no results.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2013 15:17:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76801#M19423</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2013-03-28T15:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Where Claus in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76802#M19424</link>
      <description>&lt;P&gt;Sorry if I wasn't clear. For whatever reason splunk doesn't treat OR as associative in the where clause of a stats command. This means you have to explicitly treat it as a binary operator. This means you have to do this:&lt;BR /&gt;
"where (count(foo) &amp;gt; 1 OR count(bar) &amp;gt;6 ) OR count(foobar) &amp;lt; 7"&lt;BR /&gt;
Notice the parenthesis. To abstract away, you have to do (x or y) or z , rather than x or y or z&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2013 04:52:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76802#M19424</guid>
      <dc:creator>tiberious726</dc:creator>
      <dc:date>2013-04-01T04:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Where Claus in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76803#M19425</link>
      <description>&lt;P&gt;Multiple conditions can be checked by the where clause as shown below :&lt;/P&gt;

&lt;P&gt;| inputlookup test.csv | &lt;STRONG&gt;where like&lt;/STRONG&gt;(field1, "IP") &lt;STRONG&gt;and&lt;/STRONG&gt; not &lt;STRONG&gt;like&lt;/STRONG&gt;(field2, "Pass")&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 16:25:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76803#M19425</guid>
      <dc:creator>jbanerje</dc:creator>
      <dc:date>2017-02-28T16:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Where Claus in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76804#M19426</link>
      <description>&lt;P&gt;Here's one way.  Put the category names and tests into the eval mytests statement, where the number is not 5.  Ignore any where the number &lt;EM&gt;IS&lt;/EM&gt; 5, because that will default after the join. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=foo-bar category=foo | stats count by category 
| join type=left category 
   [| makeresults | eval mytests="category1&amp;gt;7 category3&amp;gt;5 category6&amp;gt;9" 
    | makemv mytests | mvexpand mytests | makemv delim="&amp;gt;" mytests 
    | eval category=mvindex(mytests,0), limit=mvindex(mytests,1) 
    | table category, limit
    ]
| eval limit=coalesce(limit,5)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So now each category knows what its individual limit is.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where count&amp;gt;limit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And there you go.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 20:41:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Where-Claus-in-the-same-search/m-p/76804#M19426</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-28T20:41:42Z</dc:date>
    </item>
  </channel>
</rss>

