<?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: comparing multivalue fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/comparing-multivalue-fields/m-p/400772#M116068</link>
    <description>&lt;P&gt;@stevesmith08 &lt;/P&gt;

&lt;P&gt;try like this &lt;CODE&gt;| eval compare = if(match(DeviceIDlater,DeviceIDnew), 0, 1)&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Apr 2019 10:57:07 GMT</pubDate>
    <dc:creator>harishalipaka</dc:creator>
    <dc:date>2019-04-08T10:57:07Z</dc:date>
    <item>
      <title>comparing multivalue fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/comparing-multivalue-fields/m-p/400770#M116066</link>
      <description>&lt;P&gt;Good day!&lt;/P&gt;

&lt;P&gt;I need to compare the results of a search query that contains multivalued fields.&lt;/P&gt;

&lt;P&gt;My search query looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype = MySourceType earliest = 0 latest = now()
| eval category = if(_time&amp;gt;relative_time(now(), "-2h@h"), "DeviceIDnew", "DeviceIDlater")
| chart values(deviceID) by IP, category 
| eval compare = if(DeviceIDlater=DeviceIDnew, 0, 1)
| table IP, DeviceIDlater, DeviceIDnew, compare
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Despite the fact that, in most cases, the comparison is correct, I noticed that in some cases there are errors.&lt;/P&gt;

&lt;P&gt;For example:&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/6845i91D9D9B426D033F9/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
In the example above, I mean that compare = 0 because the values DeviceIDnew contained in the field DeviceIDlater.&lt;/P&gt;

&lt;P&gt;Could you help me, please? How it is correct to compare multi-value field?&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2019 19:23:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/comparing-multivalue-fields/m-p/400770#M116066</guid>
      <dc:creator>stevesmith08</dc:creator>
      <dc:date>2019-04-07T19:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: comparing multivalue fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/comparing-multivalue-fields/m-p/400771#M116067</link>
      <description>&lt;P&gt;Hi stevesmith08,&lt;/P&gt;

&lt;P&gt;If you use the field with less multi values, expand it and do the compare operation it should work just fine. Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype = MySourceType earliest = 0 latest = now()
 | eval category = if(_time&amp;gt;relative_time(now(), "-2h@h"), "DeviceIDnew", "DeviceIDlater")
 | chart values(deviceID) by IP, category 
 | mvexpand DeviceIDnew
 | eval compare = if(DeviceIDlater=DeviceIDnew, 0, 1)
 | table IP, DeviceIDlater, DeviceIDnew, compare
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will work with a small set of events, if you have millions of events try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype = MySourceType earliest = 0 latest = now()
 | eval category = if(_time&amp;gt;relative_time(now(), "-2h@h"), "DeviceIDnew", "DeviceIDlater")
 | chart values(deviceID) by IP, category 
 | stats values(*) AS * by IP DeviceIDnew
 | eval compare = if(DeviceIDlater=DeviceIDnew, 0, 1)
 | table IP, DeviceIDlater, DeviceIDnew, compare
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2019 20:59:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/comparing-multivalue-fields/m-p/400771#M116067</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-04-07T20:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: comparing multivalue fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/comparing-multivalue-fields/m-p/400772#M116068</link>
      <description>&lt;P&gt;@stevesmith08 &lt;/P&gt;

&lt;P&gt;try like this &lt;CODE&gt;| eval compare = if(match(DeviceIDlater,DeviceIDnew), 0, 1)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 10:57:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/comparing-multivalue-fields/m-p/400772#M116068</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2019-04-08T10:57:07Z</dc:date>
    </item>
  </channel>
</rss>

