<?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: case function -- why can't I operate on the results of a case function? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/case-function-why-can-t-I-operate-on-the-results-of-a-case/m-p/363099#M107259</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;it's not very clear what you are trying to do, or whats the actual problem. &lt;BR /&gt;
Please post your query and some sample events. &lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 23 Jun 2017 21:45:12 GMT</pubDate>
    <dc:creator>horsefez</dc:creator>
    <dc:date>2017-06-23T21:45:12Z</dc:date>
    <item>
      <title>case function -- why can't I operate on the results of a case function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/case-function-why-can-t-I-operate-on-the-results-of-a-case/m-p/363098#M107258</link>
      <description>&lt;P&gt;case function -- why can't I operate on the results of a case function? After the eval case function, I got 100 rows. I want to eliminate 30 of them using a standard where clause.  (ex. where fieldA = "X" should remove all rows where fieldA = "Y".)  All the rows remain. How can I exclude rows?  I need to execute 5 cases, and then at the end I want to remove what wasn't found in any of them.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 21:35:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/case-function-why-can-t-I-operate-on-the-results-of-a-case/m-p/363098#M107258</guid>
      <dc:creator>pgiffd</dc:creator>
      <dc:date>2017-06-23T21:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: case function -- why can't I operate on the results of a case function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/case-function-why-can-t-I-operate-on-the-results-of-a-case/m-p/363099#M107259</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;it's not very clear what you are trying to do, or whats the actual problem. &lt;BR /&gt;
Please post your query and some sample events. &lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 21:45:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/case-function-why-can-t-I-operate-on-the-results-of-a-case/m-p/363099#M107259</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2017-06-23T21:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: case function -- why can't I operate on the results of a case function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/case-function-why-can-t-I-operate-on-the-results-of-a-case/m-p/363100#M107260</link>
      <description>&lt;P&gt;This was getting long for a comment... &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;(ex. where fieldA = "X" should remove all rows where fieldA = "Y".)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;This is not actually correct... unset/null fields, and multivalued fields make this logic a bit more complex. &lt;CODE&gt;|where fieldA="X"&lt;/CODE&gt; keeps all rows where a value of the field is X... some of those rows could have fieldA="Y" as well.&lt;/P&gt;

&lt;P&gt;I'm going to use this runanywhere query for an example base query: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=12 | streamstats count | eval fieldA=case(count%4=1,"X",count%4=2,"Y",count%4=3,split("X,Y",","))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We have 3 rows (1,5,9) where fieldA="X", 3 rows (2,6,10) where fieldA="Y", 3 rows (3,7,11) where fieldA is both, and 3 rows (4,8,12) where fieldA is null.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;basesearch&amp;gt; | where fieldA="X"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;actually gives 6 rows (1,5,9, and 3,7,11), on half of these, fieldA="Y"  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;basesearch&amp;gt; | where NOT fieldA="Y"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which gives you 6 rows (1,5,9 and 4,8,12)... on the latter 3 now, fieldA doesn't exist, so fieldA="Y" is false &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;basesearch&amp;gt; | where fieldA!="Y"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which gives you only 3 rows (1,5,9) (or where fieldA equals a value that isn't Y)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;basesearch&amp;gt; | where isnull(fieldA)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which gives you only the 3 rows (4,8,12) where fieldA isn't any value at all&lt;/P&gt;

&lt;P&gt;This should also show that using eval with case to generate a field and then filter on it with where is indeed possible, and the last one might be what you're looking for, but as @pyro_wood mentions to solve your particular case we likely need more specific information.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 22:24:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/case-function-why-can-t-I-operate-on-the-results-of-a-case/m-p/363100#M107260</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2017-06-23T22:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: case function -- why can't I operate on the results of a case function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/case-function-why-can-t-I-operate-on-the-results-of-a-case/m-p/363101#M107261</link>
      <description>&lt;P&gt;@charlieh gave you a great answer and a demo why.  &lt;/P&gt;

&lt;P&gt;Just in case you need to understand what to do about it, here's one way...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval mynewfield=case(firsttest=1,"pass1",  secondtest="whatever","pass2",   .... lasttest="ok","lastpass",   true(),null()   )
| where isnotnull(mynewfield)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Jun 2017 23:31:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/case-function-why-can-t-I-operate-on-the-results-of-a-case/m-p/363101#M107261</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-06-23T23:31:26Z</dc:date>
    </item>
  </channel>
</rss>

