<?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 strings and find the difference in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478317#M134153</link>
    <description>&lt;P&gt;This comes up quite a bit.  First you must make &lt;CODE&gt;A&lt;/CODE&gt; and &lt;CODE&gt;B&lt;/CODE&gt; multi-valued like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| makemv delim=";" A | makemv delim=";" B ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then do something like one of these, depending on exactly what you need:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/407106/comparing-multivalue-fields-by-percentage.html"&gt;https://answers.splunk.com/answers/407106/comparing-multivalue-fields-by-percentage.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/567851/how-can-i-compare-mvfields-and-get-a-diff.html"&gt;https://answers.splunk.com/answers/567851/how-can-i-compare-mvfields-and-get-a-diff.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/740480/how-to-compare-characters-in-two-fields-and-return.html"&gt;https://answers.splunk.com/answers/740480/how-to-compare-characters-in-two-fields-and-return.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/762432/multivalue-differences.html"&gt;https://answers.splunk.com/answers/762432/multivalue-differences.html&lt;/A&gt;&lt;BR /&gt;
Don't forget to &lt;CODE&gt;UpVote&lt;/CODE&gt;!&lt;/P&gt;</description>
    <pubDate>Tue, 05 Nov 2019 05:23:02 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-11-05T05:23:02Z</dc:date>
    <item>
      <title>How to compare two strings and find the difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478315#M134151</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;In the middle of a search, I have two string fields, one is called A and the other B (both have the ";" as delimiter but the number of values inside is variable):&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;A=test;sample;example&lt;BR /&gt;
B=test;sample;example;check&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I would like to compare the two string and have the difference as result in a new field called C (so suppose C=check).&lt;BR /&gt;
Is there any way to achieve that (like doing an Excel VLOOKUP without performing a sub-search that can affect the search performance)?&lt;/P&gt;

&lt;P&gt;Thanks a lot,&lt;BR /&gt;
Edoardo&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2019 17:56:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478315#M134151</guid>
      <dc:creator>edoardo_vicendo</dc:creator>
      <dc:date>2019-11-04T17:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two strings and find the difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478316#M134152</link>
      <description>&lt;P&gt;Hi edoardo_vicendone,&lt;/P&gt;

&lt;P&gt;try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval A="test;sample;example", 
    B="test;sample;example;check" 
| makemv delim=";" A 
| makemv delim=";" B 
| mvexpand A 
| mvexpand B 
| stats values(A) AS A by B `comment(" Everything up til here creates events, please ignore ...")`
| eval C=if(B!=A, B, null())
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first 8 lines create, prepare the dummy events and the last line does the actual comparison of field &lt;CODE&gt;A&lt;/CODE&gt; and &lt;CODE&gt;B&lt;/CODE&gt; and puts the result into the new field &lt;CODE&gt;C&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;The important part of the SPL is line 4-7 where I create the multi value fields and split them so we are able to compare the values.&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2019 19:29:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478316#M134152</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-11-04T19:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two strings and find the difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478317#M134153</link>
      <description>&lt;P&gt;This comes up quite a bit.  First you must make &lt;CODE&gt;A&lt;/CODE&gt; and &lt;CODE&gt;B&lt;/CODE&gt; multi-valued like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| makemv delim=";" A | makemv delim=";" B ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then do something like one of these, depending on exactly what you need:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/407106/comparing-multivalue-fields-by-percentage.html"&gt;https://answers.splunk.com/answers/407106/comparing-multivalue-fields-by-percentage.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/567851/how-can-i-compare-mvfields-and-get-a-diff.html"&gt;https://answers.splunk.com/answers/567851/how-can-i-compare-mvfields-and-get-a-diff.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/740480/how-to-compare-characters-in-two-fields-and-return.html"&gt;https://answers.splunk.com/answers/740480/how-to-compare-characters-in-two-fields-and-return.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/762432/multivalue-differences.html"&gt;https://answers.splunk.com/answers/762432/multivalue-differences.html&lt;/A&gt;&lt;BR /&gt;
Don't forget to &lt;CODE&gt;UpVote&lt;/CODE&gt;!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 05:23:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478317#M134153</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-05T05:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two strings and find the difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478318#M134154</link>
      <description>&lt;P&gt;@woodcock &lt;BR /&gt;
Thanks a lot I have followed one of your previous solutions (see &lt;A href="https://answers.splunk.com/answers/567851/how-can-i-compare-mvfields-and-get-a-diff.html"&gt;https://answers.splunk.com/answers/567851/how-can-i-compare-mvfields-and-get-a-diff.html&lt;/A&gt;) and it worked fine&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 14:59:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478318#M134154</guid>
      <dc:creator>edoardo_vicendo</dc:creator>
      <dc:date>2019-11-05T14:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two strings and find the difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478319#M134155</link>
      <description>&lt;P&gt;@MuS &lt;BR /&gt;
Thanks a lot for your feedback!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 15:00:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-strings-and-find-the-difference/m-p/478319#M134155</guid>
      <dc:creator>edoardo_vicendo</dc:creator>
      <dc:date>2019-11-05T15:00:26Z</dc:date>
    </item>
  </channel>
</rss>

