<?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: Multivalue fields difference on multiple records in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539408#M152557</link>
    <description>&lt;P&gt;Thanks, unfortunately i'm stuck with splunk 7.2 for the moment &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Feb 2021 07:49:24 GMT</pubDate>
    <dc:creator>Viorel</dc:creator>
    <dc:date>2021-02-11T07:49:24Z</dc:date>
    <item>
      <title>Multivalue fields difference on multiple records</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539401#M152555</link>
      <description>&lt;P&gt;Hello folks,&lt;/P&gt;&lt;P&gt;I am having a hard time getting the difference between two fields of the same record, where the search query returns multiple record set.&lt;BR /&gt;&lt;BR /&gt;The query uses streamstat to bring the "previous" field into the current record, here's a dummy that shows the same results&lt;/P&gt;&lt;P&gt;| makeresults&lt;BR /&gt;| eval RoleContents = "a;b;c"&lt;BR /&gt;| eval _time = now()&lt;BR /&gt;| append [| makeresults | eval RoleContents="b;c;d" | eval _time=now()-10]&lt;BR /&gt;| append [| makeresults | eval RoleContents="a;d" | eval _time =now()-20]&lt;BR /&gt;| streamstats current=f window=1 first(RoleContents) as LastRoleContents&lt;BR /&gt;| sort _time&lt;BR /&gt;| streamstats current=f window=1 first(RoleContents) as PrevRoleContents&lt;BR /&gt;| sort - _time&lt;BR /&gt;| makemv delim=";" RoleContents&lt;BR /&gt;| makemv delim=";" PrevRoleContents&lt;BR /&gt;| table RoleContents, PrevRoleContents&lt;/P&gt;&lt;P&gt;What i am looking to acheive is within the row, to show the difference between those two fields, which will show , for each record returned, what changed in comparison to the previous record.&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 07:11:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539401#M152555</guid>
      <dc:creator>Viorel</dc:creator>
      <dc:date>2021-02-11T07:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue fields difference on multiple records</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539407#M152556</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults
| eval RoleContents = "a;b;c"
| eval _time = now()
| append [| makeresults | eval RoleContents="b;c;d" | eval _time=now()-10]
| append [| makeresults | eval RoleContents="a;d" | eval _time =now()-20]
| streamstats current=f window=1 first(RoleContents) as LastRoleContents
| sort _time
| streamstats current=f window=1 first(RoleContents) as PrevRoleContents
| sort - _time
| makemv delim=";" RoleContents
| makemv delim=";" PrevRoleContents
| eval AdditionalContents=mvmap(RoleContents,if(isnull(mvfind(PrevRoleContents,RoleContents)),RoleContents,null()))
| eval RemovedContents=mvmap(PrevRoleContents,if(isnull(mvfind(RoleContents,PrevRoleContents)),PrevRoleContents,null()))
| table RoleContents, PrevRoleContents, AdditionalContents, RemovedContents&lt;/LI-CODE&gt;&lt;P&gt;mvmap is available in splunk 8.0&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 07:47:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539407#M152556</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-11T07:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue fields difference on multiple records</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539408#M152557</link>
      <description>&lt;P&gt;Thanks, unfortunately i'm stuck with splunk 7.2 for the moment &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 07:49:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539408#M152557</guid>
      <dc:creator>Viorel</dc:creator>
      <dc:date>2021-02-11T07:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue fields difference on multiple records</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539413#M152558</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults
| eval RoleContents = "a;b;c"
| eval _time = now()
| append [| makeresults | eval RoleContents="b;c;d" | eval _time=now()-10]
| append [| makeresults | eval RoleContents="a;d" | eval _time =now()-20]
| streamstats current=f window=1 first(RoleContents) as LastRoleContents
| sort _time
| streamstats current=f window=1 first(RoleContents) as PrevRoleContents
| sort - _time
| makemv delim=";" RoleContents
| makemv delim=";" PrevRoleContents
| fields RoleContents PrevRoleContents
| streamstats count as row
| mvexpand RoleContents
| eval NewContents=if(isnull(mvfind(PrevRoleContents, RoleContents)),RoleContents,null)
| stats values(PrevRoleContents) as PrevRoleContents list(RoleContents) as RoleContents list(NewContents) as NewContents by row
| table RoleContents, PrevRoleContents, NewContents&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 11 Feb 2021 08:04:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539413#M152558</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-11T08:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue fields difference on multiple records</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539419#M152559</link>
      <description>&lt;P&gt;Awesome, can you also include the removed contents ? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 08:18:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539419#M152559</guid>
      <dc:creator>Viorel</dc:creator>
      <dc:date>2021-02-11T08:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue fields difference on multiple records</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539427#M152560</link>
      <description>&lt;P&gt;Essentially, you do the same thing with the fields swapped, however, I had to add extra logic to deal with null values since the mvexpand will remove these rows. You may need to do the same for the NewContents depending on your data.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval RoleContents = "a;b;c"
| eval _time = now()
| append [| makeresults | eval RoleContents="b;c;d" | eval _time=now()-10]
| append [| makeresults | eval RoleContents="a;d" | eval _time =now()-20]
| streamstats current=f window=1 first(RoleContents) as LastRoleContents
| sort _time
| streamstats current=f window=1 first(RoleContents) as PrevRoleContents
| sort - _time
| makemv delim=";" RoleContents
| makemv delim=";" PrevRoleContents
| fields RoleContents PrevRoleContents
| streamstats count as row
| mvexpand RoleContents
| eval NewContents=if(isnull(mvfind(PrevRoleContents, RoleContents)),RoleContents,null)
| stats values(PrevRoleContents) as PrevRoleContents list(RoleContents) as RoleContents list(NewContents) as NewContents by row
| fillnull value="not available" PrevRoleContents
| mvexpand PrevRoleContents
| eval PrevRoleContents=if(PrevRoleContents="not available",null,PrevRoleContents)
| eval RemovedContents=if(isnull(mvfind(RoleContents, PrevRoleContents)),PrevRoleContents,null)
| stats list(PrevRoleContents) as PrevRoleContents values(RoleContents) as RoleContents values(NewContents) as NewContents list(RemovedContents) as RemovedContents by row
| table RoleContents, PrevRoleContents, NewContents, RemovedContents&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 11 Feb 2021 08:36:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-difference-on-multiple-records/m-p/539427#M152560</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-11T08:36:20Z</dc:date>
    </item>
  </channel>
</rss>

