<?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 to compare column from two searches and find the difference between them and print all rows? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/608886#M211723</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt;&amp;nbsp;for sharing your inputs. Your logic worked perfectly with the usecase.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the below as well and it gave me results same as yours: -&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|eventstats dc(rectype) as rectypes by index, pair
|where NOT (rectypes=2) AND rectype="lookup" AND rectype!="index"&lt;/LI-CODE&gt;&lt;P&gt;Do you find if I have missed any condition by removing mvcount and isnotnull from the code you shared?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2022 17:47:10 GMT</pubDate>
    <dc:creator>Taruchit</dc:creator>
    <dc:date>2022-08-09T17:47:10Z</dc:date>
    <item>
      <title>How to compare column from two searches and find the difference between them and print all rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/312955#M93669</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;Thanks for your time. Im using splunk to parse the log. &lt;BR /&gt;
I have two search. the columns i got from A is as below &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;tktnum, prcnum, type
Columns for search B is 
tktnum, _time. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How may I find tktnum existed in A but not in B then print table like &lt;BR /&gt;
tktnum(In A not B), prcnum, type&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search A with tktnum, prcnum, type 
| stats values(tktnum) as TKT1, values(prcnum) as PRCNUM, values(ftrectyp) as TYPE
    | appendcols [search B with tktnum] 
    | stats values(tktnum) as TKT2 ] 
| makemv TKT1
| makemv TYPE
| mvexpand TKT1
| mvexpand TYPE
| where not match(TKT2, TKT1) 
| table TKT1, TYPE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I do get the tktnum which exist in A, not in B. But the problem is TYPE not match. Can anyone help on it. &lt;BR /&gt;
The type should be corresponding to that tktnum from the original row, but now I got is different.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 18:28:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/312955#M93669</guid>
      <dc:creator>hakusama1024</dc:creator>
      <dc:date>2018-02-26T18:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare column from two searches and find the difference between them and print all rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/312956#M93670</link>
      <description>&lt;P&gt;This is pretty straightforward since the results from Search B contain a field that's not present in Search A. Combine the two searches at the outset so that you first gather all results from both searches. Then use the &lt;CODE&gt;eventstats&lt;/CODE&gt; command to copy the &lt;CODE&gt;_time&lt;/CODE&gt; field from results from Search B to results from Search A with the same &lt;CODE&gt;tktnum&lt;/CODE&gt;, and finally filter down to only events that don't contain a &lt;CODE&gt;_time&lt;/CODE&gt; field, as these are tickets that had results in Search A but not in Search B.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ combined Search A and Search B ]
| eventstats first(_time) AS _time BY tktnum
| where isnull(_time)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Feb 2018 19:31:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/312956#M93670</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-02-26T19:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare column from two searches and find the difference between them and print all rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/312957#M93671</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search A with tktnum, prcnum, type
| where NOT [search B with tktnum _time | table tktnum]
| renamte tktnum as "tktnum(in A not B)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Based on type of queries for search A, you could actually move the NOT filter to base search of A (search portion before first pipe symbol).&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 20:06:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/312957#M93671</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-02-26T20:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare column from two searches and find the difference between them and print all rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/608848#M211708</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/73198"&gt;@elliotproebstel&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I also have a similar requirement of searching results based on a column.&lt;BR /&gt;The below is the search results of SPL: -&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;index&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;host&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;pair&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;rectype&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="47px"&gt;idx1&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;hostA&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;Pair1&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;index&lt;BR /&gt;lookup&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;idx1&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;hostB&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Pair1&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;lookup&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="47px"&gt;idx2&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;hostC&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;Pair2&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;index&lt;BR /&gt;lookup&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;idx2&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;hostD&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Pair3&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;lookup&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;idx2&lt;/TD&gt;&lt;TD height="25px"&gt;hostE&lt;/TD&gt;&lt;TD height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD height="25px"&gt;lookup&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="47px"&gt;idx3&lt;/TD&gt;&lt;TD height="47px"&gt;hostF&lt;/TD&gt;&lt;TD height="47px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD height="47px"&gt;index&lt;BR /&gt;lookup&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the above table, I have idx1 which has 2 host values: hostA, hostB; but, common pair value: Pair1.&amp;nbsp;&lt;BR /&gt;rectype is a multi-value field, for hostA, rectype is "index lookup" and for hostB, rectype is "lookup".&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need your help to filter such records where if pair value is same and rectype values are different, along with rectype cell having values "index lookup".&lt;/P&gt;&lt;P&gt;Thus, from the above search output, I need to filter out rows having value: - hostA, hostB, hostC, hostF; and display rows with values with hostD, hostE.&lt;/P&gt;&lt;P&gt;Reason for filtering rows with hostA and hostB: -&amp;nbsp;&lt;BR /&gt;-&amp;gt; Pair value is same.&lt;BR /&gt;-&amp;gt; rectype values are different.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Reason for filtering out hostC: -&lt;BR /&gt;-&amp;gt; rectype value is "index lookup".&lt;/P&gt;&lt;P&gt;Reason for filtering out hostF: -&lt;BR /&gt;-&amp;gt; rectype value is "index lookup".&lt;/P&gt;&lt;P&gt;Thus, the expected output after applying filter on above search result is: -&lt;/P&gt;&lt;TABLE border="1" width="277px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="69.25px" height="25px"&gt;&lt;STRONG&gt;index&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="69.25px" height="25px"&gt;&lt;STRONG&gt;host&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="69.25px" height="25px"&gt;&lt;STRONG&gt;pair&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="69.25px" height="25px"&gt;&lt;STRONG&gt;rectype&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="69.25px" height="25px"&gt;idx2&lt;/TD&gt;&lt;TD width="69.25px" height="25px"&gt;hostD&lt;/TD&gt;&lt;TD width="69.25px" height="25px"&gt;Pair3&lt;/TD&gt;&lt;TD width="69.25px" height="25px"&gt;lookup&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="69.25px" height="25px"&gt;idx2&lt;/TD&gt;&lt;TD width="69.25px" height="25px"&gt;hostE&lt;/TD&gt;&lt;TD width="69.25px" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="69.25px" height="25px"&gt;lookup&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help by sharing your inputs.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 12:46:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/608848#M211708</guid>
      <dc:creator>Taruchit</dc:creator>
      <dc:date>2022-08-09T12:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare column from two searches and find the difference between them and print all rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/608863#M211712</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Your current search with field index host pair rectype
| eventstats dc(rectype) as rectypes by index pair
| where NOT (rectypes=2 OR (mvcount(rectype)=2 AND isnotnull(mvfind(rectype,"(index|lookup)"))))&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 09 Aug 2022 13:39:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/608863#M211712</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2022-08-09T13:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare column from two searches and find the difference between them and print all rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/608886#M211723</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt;&amp;nbsp;for sharing your inputs. Your logic worked perfectly with the usecase.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the below as well and it gave me results same as yours: -&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|eventstats dc(rectype) as rectypes by index, pair
|where NOT (rectypes=2) AND rectype="lookup" AND rectype!="index"&lt;/LI-CODE&gt;&lt;P&gt;Do you find if I have missed any condition by removing mvcount and isnotnull from the code you shared?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 17:47:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/608886#M211723</guid>
      <dc:creator>Taruchit</dc:creator>
      <dc:date>2022-08-09T17:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare column from two searches and find the difference between them and print all rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/608891#M211727</link>
      <description>&lt;P&gt;Will following row be included in the result? Will there be any record with just rectype=index?&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;idx4&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;hostG&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Pair4&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;index&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If no, then your logic is correct. In fact, 2nd condition is (below) is not required. (if rectype=lookup, it'll never be index, so it's a deadcode)&lt;/P&gt;&lt;PRE&gt;AND rectype!="index"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 19:06:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/608891#M211727</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2022-08-09T19:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare column from two searches and find the difference between them and print all rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/609153#M211817</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thank you for your prompt response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my case, I do have records with rectype=index.&lt;/P&gt;&lt;P&gt;But, for my current usecase I need to filter out those records, so it seems the code logic is fine.&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 12:01:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-column-from-two-searches-and-find-the-difference/m-p/609153#M211817</guid>
      <dc:creator>Taruchit</dc:creator>
      <dc:date>2022-08-11T12:01:03Z</dc:date>
    </item>
  </channel>
</rss>

