<?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: Correlation based on 3 fields and find events in between, one of the fields in multivalue in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Correlation-based-on-3-fields-and-find-events-in-between-one-of/m-p/356338#M170100</link>
    <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval temp="4/4/2014,VW,Jetta,123,battery,#4/5/2014,RR,Phantom,234,\"head light\" \"rear light\",#4/6/2014,Renault,Clio,345,engine,#4/4/2015,VW,Jetta,123,battery alternator,#4/5/2015,RR,Phantom,234,bumper,##4/6/2015,Renault,Clio,345,transmission,#4/6/2016,Renault,Clio,345,engine," | makemv temp delim="#" | mvexpand temp | table temp | rex field=temp "(?&amp;lt;date&amp;gt;[^,]+),(?&amp;lt;make&amp;gt;[^,]+),(?&amp;lt;model&amp;gt;[^,]+),(?&amp;lt;carid&amp;gt;[^,]+),(?&amp;lt;replaced_parts&amp;gt;[^,]+),"  
| rename COMMENT as "Above portion generates the sample data"
| eval date=strptime(date,"%m/%d/%Y") | eval replaced_parts=if(match(replaced_parts,"\""),replace(replace(replaced_parts,"\"\s+\"",","),"\"",""),replace(replaced_parts,"\s+",",")) | makemv replaced_parts delim="," | mvexpand replaced_parts 
| rename COMMENT as "Above portion expands the replaced_parts in case there are multiple parts "
| eventstats dc(date) as dates by make model carid replaced_parts | eval common_parts=if(dates&amp;gt;1,replaced_parts,null()) | eval alternate_parts=if(dates=1,replaced_parts,null()) | stats max(date) as last_date max(dates) as dates values(*_parts) as *_parts by carid model make | where dates=2 | table  last_date  carid make model common_parts alternate_parts | eval last_date=strftime(last_date,"%m/%d/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 23 Apr 2018 18:58:19 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-04-23T18:58:19Z</dc:date>
    <item>
      <title>Correlation based on 3 fields and find events in between, one of the fields in multivalue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Correlation-based-on-3-fields-and-find-events-in-between-one-of/m-p/356337#M170099</link>
      <description>&lt;P&gt;Hello Splunkers,&lt;BR /&gt;
battling with this all morning and seeking your assistance.&lt;BR /&gt;
i have a CSV data set from a car workshop as below, the field "replaced_parts" is a product number and can take any number of values, here i changed to part name for convenience. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;date,make,model,car_id,replaced_parts,
4/4/2014,VW,Jetta,123,battery,
4/5/2014,RR,Phantom,234,"head light" "rear light",
4/6/2014,Renault,Clio,345,engine,
4/4/2015,VW,Jetta,123,battery alternator,
4/5/2015,RR,Phantom,234,bumper",
4/6/2015,Renault,Clio,345,transmission,
4/6/2016,Renault,Clio,345,engine,
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i am trying to find whether the same &lt;CODE&gt;car_id&lt;/CODE&gt; had the same part replaced in consecutive visits to the shop as well as other parts that might had impact on that replaced part. for example car # 123 should appear and car # 234 should not.&lt;BR /&gt;
also, i am trying to capture whether the same car was in another visit and replaced another part/s and place that value/s in a new field.&lt;BR /&gt;
example desired result would be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;last_date|car_id |make  |model|commun_replaced_parts|maybe_related_part
4/4/2015|123   | VW       |Jetta   |battery                                |alternator,
4/6/2016|345   |Renault|Clio    |engine                                 |transmission
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;thanks in advance for your help&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 17:24:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Correlation-based-on-3-fields-and-find-events-in-between-one-of/m-p/356337#M170099</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-04-23T17:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation based on 3 fields and find events in between, one of the fields in multivalue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Correlation-based-on-3-fields-and-find-events-in-between-one-of/m-p/356338#M170100</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval temp="4/4/2014,VW,Jetta,123,battery,#4/5/2014,RR,Phantom,234,\"head light\" \"rear light\",#4/6/2014,Renault,Clio,345,engine,#4/4/2015,VW,Jetta,123,battery alternator,#4/5/2015,RR,Phantom,234,bumper,##4/6/2015,Renault,Clio,345,transmission,#4/6/2016,Renault,Clio,345,engine," | makemv temp delim="#" | mvexpand temp | table temp | rex field=temp "(?&amp;lt;date&amp;gt;[^,]+),(?&amp;lt;make&amp;gt;[^,]+),(?&amp;lt;model&amp;gt;[^,]+),(?&amp;lt;carid&amp;gt;[^,]+),(?&amp;lt;replaced_parts&amp;gt;[^,]+),"  
| rename COMMENT as "Above portion generates the sample data"
| eval date=strptime(date,"%m/%d/%Y") | eval replaced_parts=if(match(replaced_parts,"\""),replace(replace(replaced_parts,"\"\s+\"",","),"\"",""),replace(replaced_parts,"\s+",",")) | makemv replaced_parts delim="," | mvexpand replaced_parts 
| rename COMMENT as "Above portion expands the replaced_parts in case there are multiple parts "
| eventstats dc(date) as dates by make model carid replaced_parts | eval common_parts=if(dates&amp;gt;1,replaced_parts,null()) | eval alternate_parts=if(dates=1,replaced_parts,null()) | stats max(date) as last_date max(dates) as dates values(*_parts) as *_parts by carid model make | where dates=2 | table  last_date  carid make model common_parts alternate_parts | eval last_date=strftime(last_date,"%m/%d/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Apr 2018 18:58:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Correlation-based-on-3-fields-and-find-events-in-between-one-of/m-p/356338#M170100</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-04-23T18:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation based on 3 fields and find events in between, one of the fields in multivalue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Correlation-based-on-3-fields-and-find-events-in-between-one-of/m-p/356339#M170101</link>
      <description>&lt;P&gt;@somesoni2, thank you very much! &lt;BR /&gt;
works nice like the RR&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 19:10:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Correlation-based-on-3-fields-and-find-events-in-between-one-of/m-p/356339#M170101</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-04-23T19:10:22Z</dc:date>
    </item>
  </channel>
</rss>

