<?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: Why does the subsearch not exclude the results from main search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-subsearch-not-exclude-the-results-from-main-search/m-p/463006#M130541</link>
    <description>&lt;P&gt;You should be able to just flip your greater than to a less than or equal.  The only other difference in your queries is the asset_atp="false" and it just excludes more things. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index asset_type="Workstation" asset_status="ACTIVE" asset_atp="false" earliest=-1d@d latest=-0d@d 
| eval nexttime=strftime(relative_time(now(),"-w@w") ,"%Y-%m-%d %H:%M:%S") 
| where ad_date_created&amp;lt;=nexttime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 18 Oct 2019 14:26:43 GMT</pubDate>
    <dc:creator>kmaron</dc:creator>
    <dc:date>2019-10-18T14:26:43Z</dc:date>
    <item>
      <title>Why does the subsearch not exclude the results from main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-subsearch-not-exclude-the-results-from-main-search/m-p/463003#M130538</link>
      <description>&lt;P&gt;I have the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index asset_type="Workstation" asset_atp="false" asset_status="ACTIVE" earliest=-1d@d latest=-0d@d
| search NOT
    [search index=my_index asset_type="Workstation"  asset_status="ACTIVE" earliest=-1d@d latest=-0d@d
| eval nexttime=strftime(relative_time(now(),"-w@w") ,"%Y-%m-%d %H:%M:%S")
| where ad_date_created&amp;gt;nexttime]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When i run the searches separately, the first one returns 1841 events and the second one returns 487 events.&lt;BR /&gt;
But the combined search does not exclude the results from the second search so I get the full 1841 events again.&lt;/P&gt;

&lt;P&gt;When I use those searches with stats, just to get the count of the events, everything looks fine and I get the deisred result of 1354 with the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index asset_type="Workstation" asset_atp="false" asset_status="ACTIVE" earliest=-1d@d latest=-0d@d
| stats count as TotalA
| appendcols 
[search index=my_index asset_type="Workstation"  asset_status="ACTIVE" earliest=-1d@d latest=-0d@d
| eval nexttime=strftime(relative_time(now(),"-w@w") ,"%Y-%m-%d %H:%M:%S")
| where ad_date_created&amp;gt;nexttime
| stats count as TotalB]
| eval Total=TotalA-TotalB
| fields Total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What am I doing wrong?&lt;/P&gt;

&lt;P&gt;Thanks in advance for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 09:29:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-subsearch-not-exclude-the-results-from-main-search/m-p/463003#M130538</guid>
      <dc:creator>mmarinov</dc:creator>
      <dc:date>2019-10-18T09:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the subsearch not exclude the results from main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-subsearch-not-exclude-the-results-from-main-search/m-p/463004#M130539</link>
      <description>&lt;P&gt;Hi nmarinov,&lt;/P&gt;

&lt;P&gt;Can you pleae try the below query and let me know whether it is working as expected.&lt;BR /&gt;
index=my_index asset_atp="false" earliest=-1d@d latest=-0d@d | eval ExceptionType=if(searchmatch ("Workstation"), ("ACTIVE"),("false")&lt;BR /&gt;
| eventstats dc(ExceptionType) AS numExceptionTypes values(ExceptionType) AS ExceptionTypes | search numExceptionTypes=1 AND ExceptionType="false"&lt;/P&gt;

&lt;P&gt;I have tried my level best based on your inputs. Lets c &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:39:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-subsearch-not-exclude-the-results-from-main-search/m-p/463004#M130539</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2020-09-30T02:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the subsearch not exclude the results from main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-subsearch-not-exclude-the-results-from-main-search/m-p/463005#M130540</link>
      <description>&lt;P&gt;Hi kartm,&lt;/P&gt;

&lt;P&gt;Unfortunately, yout query does not return any results.&lt;/P&gt;

&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 10:31:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-subsearch-not-exclude-the-results-from-main-search/m-p/463005#M130540</guid>
      <dc:creator>mmarinov</dc:creator>
      <dc:date>2019-10-18T10:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the subsearch not exclude the results from main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-subsearch-not-exclude-the-results-from-main-search/m-p/463006#M130541</link>
      <description>&lt;P&gt;You should be able to just flip your greater than to a less than or equal.  The only other difference in your queries is the asset_atp="false" and it just excludes more things. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index asset_type="Workstation" asset_status="ACTIVE" asset_atp="false" earliest=-1d@d latest=-0d@d 
| eval nexttime=strftime(relative_time(now(),"-w@w") ,"%Y-%m-%d %H:%M:%S") 
| where ad_date_created&amp;lt;=nexttime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Oct 2019 14:26:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-subsearch-not-exclude-the-results-from-main-search/m-p/463006#M130541</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2019-10-18T14:26:43Z</dc:date>
    </item>
  </channel>
</rss>

