<?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: Mvfields comparison in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-quot-list-quot-and-quot-standard-quot/m-p/635884#M220912</link>
    <description>&lt;P&gt;Assuming host is not null, this is one way of doing it although possibly not the most efficient&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats values(list) as list values(standard) as standard by host
| mvexpand list
| mvexpand standard
| eval list_in_standard = if(list==standard,list,null())
| stats values(list_in_standard) as list_in_standard values(standard) as standard by host list
| eval list_not_in_standard=if(isnull(list_in_standard),list,null())
| mvexpand standard
| eval standard_in_list = if(list==standard,standard,null())
| stats values(list_in_standard) as list_in_standard values(standard_in_list) as standard_in_list values(list) as list values(list_not_in_standard) as list_not_in_standard by host standard
| eval standard_not_in_list=if(isnull(standard_in_list),standard,null())
| stats values(list) as list values(standard) as standard values(list_in_standard) as list_iin_standard values(standard_not_in_list) as standard_not_in_list values(list_not_in_standard) as list_not_in_standard by host&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 24 Mar 2023 10:42:54 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2023-03-24T10:42:54Z</dc:date>
    <item>
      <title>How to compare fields "list" and "standard"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-quot-list-quot-and-quot-standard-quot/m-p/635868#M220907</link>
      <description>&lt;P&gt;Hello everyone&lt;/P&gt;
&lt;P&gt;In the result of my search I got such results (last command was stats values(list) as list, values(standard) as standard by host&amp;nbsp;&lt;BR /&gt;fields list and standard are multivalues&lt;/P&gt;
&lt;TABLE border="1" width="56.25%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;host&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;list&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;standard&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;5&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="27px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="27px"&gt;2&lt;/TD&gt;
&lt;TD height="27px"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to compare fields "list" and "standard"&lt;/P&gt;
&lt;P&gt;make field "result" where will be: lacking records, redundant records and passing records&lt;BR /&gt;Lacking is record that present in standard but not in list, redundant is present in list but not in standard, and passing is which is in list and standard is equal.&lt;BR /&gt;&lt;BR /&gt;so for this example must be:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;result&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;Passing:&lt;BR /&gt;1&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;Lacking:&lt;/P&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;P&gt;Redundant:&lt;/P&gt;
&lt;P&gt;5&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 24 Mar 2023 16:33:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-quot-list-quot-and-quot-standard-quot/m-p/635868#M220907</guid>
      <dc:creator>bosseres</dc:creator>
      <dc:date>2023-03-24T16:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Mvfields comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-quot-list-quot-and-quot-standard-quot/m-p/635884#M220912</link>
      <description>&lt;P&gt;Assuming host is not null, this is one way of doing it although possibly not the most efficient&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats values(list) as list values(standard) as standard by host
| mvexpand list
| mvexpand standard
| eval list_in_standard = if(list==standard,list,null())
| stats values(list_in_standard) as list_in_standard values(standard) as standard by host list
| eval list_not_in_standard=if(isnull(list_in_standard),list,null())
| mvexpand standard
| eval standard_in_list = if(list==standard,standard,null())
| stats values(list_in_standard) as list_in_standard values(standard_in_list) as standard_in_list values(list) as list values(list_not_in_standard) as list_not_in_standard by host standard
| eval standard_not_in_list=if(isnull(standard_in_list),standard,null())
| stats values(list) as list values(standard) as standard values(list_in_standard) as list_iin_standard values(standard_not_in_list) as standard_not_in_list values(list_not_in_standard) as list_not_in_standard by host&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Mar 2023 10:42:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-quot-list-quot-and-quot-standard-quot/m-p/635884#M220912</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-03-24T10:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Mvfields comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-quot-list-quot-and-quot-standard-quot/m-p/635886#M220913</link>
      <description>&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 10:44:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-quot-list-quot-and-quot-standard-quot/m-p/635886#M220913</guid>
      <dc:creator>bosseres</dc:creator>
      <dc:date>2023-03-24T10:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare fields "list" and "standard"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-quot-list-quot-and-quot-standard-quot/m-p/636013#M220938</link>
      <description>&lt;P&gt;To address &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;'s efficiency considerations, here is a literal implementation of your requirements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;``` uses side effect of SPL's liberal equality operator ```
| eval lacking = mvmap(standard, if(standard == list, null(), standard))
| eval redundant = mvmap(list, if(list == standard, null(), list))
| eval passing = mvmap(list, if(list == standard, list, null()))
| eval result = json_object("lacking", lacking, "redundant", redundant, "passing", passing)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Your description of a &lt;EM&gt;field&lt;/EM&gt;&amp;nbsp;named &lt;FONT face="andale mono,times"&gt;result&lt;/FONT&gt; requires an associative array, or hash representation, that doesn't come native in SPL. &amp;nbsp;So, you can either use three separate fields as implemented in the first three lines or use a JSON representation which SPL added in 8.0, as created in line 4.&lt;/P&gt;&lt;P&gt;Using your sample data in this emulation,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval list = mvappend("5", "1", "2", "3"), standard = mvappend("1", "2", "3", "4"), host = "hostA"
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the result is&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;host&lt;/TD&gt;&lt;TD&gt;lacking&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;list&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;passing&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;redundant&lt;/TD&gt;&lt;TD&gt;result&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;standard&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;hostA&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;5&lt;/DIV&gt;&lt;DIV class=""&gt;1&lt;/DIV&gt;&lt;DIV class=""&gt;2&lt;/DIV&gt;&lt;DIV class=""&gt;3&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;1&lt;/DIV&gt;&lt;DIV class=""&gt;2&lt;/DIV&gt;&lt;DIV class=""&gt;3&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;{"lacking":4,"redundant":5,"passing":["1","2","3"]}&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;1&lt;/DIV&gt;&lt;DIV class=""&gt;2&lt;/DIV&gt;&lt;DIV class=""&gt;3&lt;/DIV&gt;&lt;DIV class=""&gt;4&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Again, the use of "result" field is optional in my opinion.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2023 07:30:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-quot-list-quot-and-quot-standard-quot/m-p/636013#M220938</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-03-25T07:30:00Z</dc:date>
    </item>
  </channel>
</rss>

