<?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 two fields from two different searches and display results with matches and mis-matches? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441015#M125324</link>
    <description>&lt;P&gt;Following on hasham19833 answer (&lt;A href="https://answers.splunk.com/comments/754583/view.html"&gt;https://answers.splunk.com/comments/754583/view.html&lt;/A&gt;)&lt;BR /&gt;
This search &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=tst_aaa AND id_a=*) OR (index=tst_bbb AND id_b = *) 
| eval id = if(isnull(id_a), id_b, id_a)
| stats values(id_a) as id_a values(id_b) as id_b by id
| eval m = if(isnull(id_a) OR isnull(id_b), "not matched", "matched")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will produce&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id    id_a    id_b  m
1111    1111    1111    matched
2222    2222            not matched
2424    2424            not matched
3333    3333    3333    matched
3344           3344 not matched
4444    4444    4444    matched
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Jun 2019 01:24:20 GMT</pubDate>
    <dc:creator>ilyaresh</dc:creator>
    <dc:date>2019-06-26T01:24:20Z</dc:date>
    <item>
      <title>How to compare two fields from two different searches and display results with matches and mis-matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441010#M125319</link>
      <description>&lt;P&gt;I am running 2 different searches and have to compare the each value in one field with the values in the other field. The display result should show a match or a mismatch against each value.&lt;/P&gt;

&lt;P&gt;given data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Field A:
1111
2222
2424
3333
4444

Field B:
3333
1111
4444
3344
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results should be something like this table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Field A -- Field B ---- results
1111 --- 1111  ----match
2222----            ---- no-match
3333----  3333 ---- match
4444---- 44444----match
2424 ----           ----  no match
         ----   3344 ---- not match
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jun 2019 08:10:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441010#M125319</guid>
      <dc:creator>hasham19833</dc:creator>
      <dc:date>2019-06-25T08:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two fields from two different searches and display results with matches and mis-matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441011#M125320</link>
      <description>&lt;P&gt;Hi @hasham19833,&lt;/P&gt;

&lt;P&gt;Are those values in the same events, could you share your search ?&lt;/P&gt;

&lt;P&gt;If the fields are on the same line it should be like this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YourBaseSearch 
| eval results=if(FieldA==FieldB, "match","not match")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or else you will have to join both events and then add the logic above.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 10:27:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441011#M125320</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-25T10:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two fields from two different searches and display results with matches and mis-matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441012#M125321</link>
      <description>&lt;P&gt;See the search query below; So its searching from 2 different indexes, index AS is event based, and the field "eventKey" appears in every result. While the 2nd field is from index DS and is extracted from a large xml file, so im guessing its multivalue field. That field is "availId". Now i want to see which individual values from 'availId' is matching with the values of field eventKey.&lt;/P&gt;

&lt;P&gt;(index=DS sourcetype=SCHed source="/archived/ABC.SCH") OR (index=AS sourcetype=ASED "Finished" earliest=-19hr latest=-7hr )&lt;BR /&gt;
| spath output=availId path=Schedule.Window.Avail{@availId}&lt;BR /&gt;
| mvexpand availId&lt;BR /&gt;
| eval results=if(availId==eventKey, "match","not match")&lt;BR /&gt;
| table availId results&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 12:10:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441012#M125321</guid>
      <dc:creator>hasham19833</dc:creator>
      <dc:date>2019-06-25T12:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two fields from two different searches and display results with matches and mis-matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441013#M125322</link>
      <description>&lt;P&gt;In your case availID and eventKey are never on the same line. You need to join the events from the two indices using a key. &lt;/P&gt;

&lt;P&gt;Something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
|stats values(availID) as availID values(eventKey) as eventKey by JoinKey
...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jun 2019 12:17:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441013#M125322</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-25T12:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two fields from two different searches and display results with matches and mis-matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441014#M125323</link>
      <description>&lt;P&gt;this is not giving out any results. there is nothing common between the 2 events, except the IDs, which are again by different field titles. is there anyway that i can combine the values from 2 fields into one field so that all the ids (even duplicates or common are in the same field)?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 12:46:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441014#M125323</guid>
      <dc:creator>hasham19833</dc:creator>
      <dc:date>2019-06-25T12:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two fields from two different searches and display results with matches and mis-matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441015#M125324</link>
      <description>&lt;P&gt;Following on hasham19833 answer (&lt;A href="https://answers.splunk.com/comments/754583/view.html"&gt;https://answers.splunk.com/comments/754583/view.html&lt;/A&gt;)&lt;BR /&gt;
This search &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=tst_aaa AND id_a=*) OR (index=tst_bbb AND id_b = *) 
| eval id = if(isnull(id_a), id_b, id_a)
| stats values(id_a) as id_a values(id_b) as id_b by id
| eval m = if(isnull(id_a) OR isnull(id_b), "not matched", "matched")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will produce&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id    id_a    id_b  m
1111    1111    1111    matched
2222    2222            not matched
2424    2424            not matched
3333    3333    3333    matched
3344           3344 not matched
4444    4444    4444    matched
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jun 2019 01:24:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441015#M125324</guid>
      <dc:creator>ilyaresh</dc:creator>
      <dc:date>2019-06-26T01:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two fields from two different searches and display results with matches and mis-matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441016#M125325</link>
      <description>&lt;P&gt;Hi @hasham19833 ,&lt;/P&gt;

&lt;P&gt;You might try something like this:&lt;BR /&gt;
&lt;PRE&gt;(index=DS sourcetype=SCHed source="/archived/ABC.SCH") OR (index=AS sourcetype=ASED "Finished" earliest=-19hr latest=-7hr )&lt;BR /&gt;
| spath output=availId path=Schedule.Window.Avail{@availId}&lt;BR /&gt;
| eval AllKeys = coalesce(eventKey, availId)&lt;BR /&gt;
| stats values(eventKey) as eventKey values(availId) as availId by AllKeys&lt;BR /&gt;
| eval CheckMatch = if(eventKey == availId, "Match", "No Match")&lt;/PRE&gt;&lt;BR /&gt;
This works if availId is &lt;EM&gt;NOT&lt;/EM&gt; a multi-value field.  If it &lt;EM&gt;IS&lt;/EM&gt; a multi-value field, you will need to do something like this:&lt;BR /&gt;
&lt;PRE&gt;(index=DS sourcetype=SCHed source="/archived/ABC.SCH") OR (index=AS sourcetype=ASED "Finished" earliest=-19hr latest=-7hr )&lt;BR /&gt;
| spath output=availId path=Schedule.Window.Avail{@availId}&lt;BR /&gt;
| eval availId = if(isnull(availId), "-", availId) &lt;BR /&gt;
| mvexpand availId &lt;BR /&gt;
| eval availId = case( availId!="-", availId )&lt;BR /&gt;
| eval AllKeys = coalesce(eventKey, availId) &lt;BR /&gt;
| stats values(eventKey) as eventKey values(availId) as availId by AllKeys &lt;BR /&gt;
| eval CheckMatch = if(eventKey == availId, "Match", "No Match")&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;Here is what it might look like:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7246iA0458414624295CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 02:26:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-fields-from-two-different-searches-and/m-p/441016#M125325</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2019-06-26T02:26:45Z</dc:date>
    </item>
  </channel>
</rss>

