<?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: NOT IN Subquery syntax in Other Usage</title>
    <link>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570547#M1012</link>
    <description>&lt;P&gt;In order to find an event that did not occur later than one that did you are going to have to use a different method. I don't believe it will be possible to use the subquery to filter the parent query as you are trying.&lt;/P&gt;&lt;P&gt;Instead I would suggest you need to use stats, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main sourcetype=access_combined_wcookie (action=returned OR action=purchase)
| stats latest(action) as lastAction by productId clientIp
| where lastAction="returned"&lt;/LI-CODE&gt;&lt;P&gt;This will give you the last action for the product/clientIp and then you just want to see if the last action is returned.&lt;/P&gt;&lt;P&gt;Naturally within your search results, the clientIp may have had any number of 'transactions' for that productId, so you will need to consider how you want to address that.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Oct 2021 02:10:10 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2021-10-12T02:10:10Z</dc:date>
    <item>
      <title>NOT IN Subquery syntax</title>
      <link>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570545#M1011</link>
      <description>&lt;P&gt;hello, everyone&lt;/P&gt;&lt;P&gt;I have a question about how to write a subquery in Splunk.&lt;/P&gt;&lt;P&gt;for example&lt;BR /&gt;I would like to get a list of productId that was returned, but later was not purchased again.&lt;BR /&gt;NOT IN Subquery part.&lt;/P&gt;&lt;P&gt;How can I accomplish this?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;index=main sourcetype=access_combined_wcookie action=returned&lt;BR /&gt;NOT IN [search index=main sourcetype=access_combined_wcookie action=purchase&lt;BR /&gt;|table clientip]&lt;BR /&gt;| stats count, dc(productId) by clientip&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 01:18:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570545#M1011</guid>
      <dc:creator>ycho1</dc:creator>
      <dc:date>2021-10-12T01:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: NOT IN Subquery syntax</title>
      <link>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570547#M1012</link>
      <description>&lt;P&gt;In order to find an event that did not occur later than one that did you are going to have to use a different method. I don't believe it will be possible to use the subquery to filter the parent query as you are trying.&lt;/P&gt;&lt;P&gt;Instead I would suggest you need to use stats, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main sourcetype=access_combined_wcookie (action=returned OR action=purchase)
| stats latest(action) as lastAction by productId clientIp
| where lastAction="returned"&lt;/LI-CODE&gt;&lt;P&gt;This will give you the last action for the product/clientIp and then you just want to see if the last action is returned.&lt;/P&gt;&lt;P&gt;Naturally within your search results, the clientIp may have had any number of 'transactions' for that productId, so you will need to consider how you want to address that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 02:10:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570547#M1012</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-10-12T02:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: NOT IN Subquery syntax</title>
      <link>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570561#M1013</link>
      <description>&lt;P&gt;There can be probably more than one approach to your problem (one was already presented) but the subquery will not work this way.&lt;/P&gt;&lt;P&gt;As subquery is executed and the results are returned, they are "pasted" into the original query as a condition using field names and values returned from the subquery.&lt;/P&gt;&lt;P&gt;So the IN operator will not with them. With it after subquery expansion you'd have (hypoteticaly - it's not a valid syntax) something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main sourcetype=access_combined_wcookie action=returned
NOT IN (clientip=value1 OR clientip=value2 OR ...)&lt;/LI-CODE&gt;&lt;P&gt;The last() approach that &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; showed is a neat trick but relies on the time succession.&lt;/P&gt;&lt;P&gt;It might be ok, but you might as well need something a bit different. Depends on your actual data.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 05:43:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570561#M1013</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-10-12T05:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: NOT IN Subquery syntax</title>
      <link>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570678#M1014</link>
      <description>&lt;P&gt;Technically it is possible to get the subsearch to return a search string that will work with NOT IN, the syntax would be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search&amp;gt; NOT your_field IN  [
  search &amp;lt;search&amp;gt;
  | stats count by your_field
  | fields your_field
  | rename your_field as search
  | format "(" "" "" "" "" ")" ]&lt;/LI-CODE&gt;&lt;P&gt;but there is no value in this for the OP's problem, as this will not handle the basic problem of how to determine which event came after.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 21:04:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570678#M1014</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-10-12T21:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: NOT IN Subquery syntax</title>
      <link>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570702#M1015</link>
      <description>&lt;P&gt;Nice to know. I always thought you could only return results as key/value pairs which get interpreted as additional conditions. Can you return any arbitrary string?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 05:25:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570702#M1015</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-10-13T05:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: NOT IN Subquery syntax</title>
      <link>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570729#M1016</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Take a look at the format command, the 6 components give you quite a lot of flexibility in returning different ways&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.2/SearchReference/Format" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.2/SearchReference/Format&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 09:49:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570729#M1016</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-10-13T09:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: NOT IN Subquery syntax</title>
      <link>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570734#M1017</link>
      <description>&lt;P&gt;Good to know. That's what I needed.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 10:07:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/NOT-IN-Subquery-syntax/m-p/570734#M1017</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-10-13T10:07:40Z</dc:date>
    </item>
  </channel>
</rss>

