<?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: lose one event if another one exists using dedup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138110#M37886</link>
    <description>&lt;P&gt;Try following (assuming we get only two duplicate entries, one with amended value and one with "Unknown")&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search for some stuff | append [previousoutput.csv] |eval field3=if(is null(field3),"unknown",field3)
 | dedup field1, field2, field3| mvcombine field3 delim="," |eval val1=mvindex(field3,0) | eval val2=mvindex(field3,1) | eval field3=case(val1="Unknown" AND isnotnull(val2), val2, 1=1,val1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This combines field3 for duplicate values for field1 and field2 (field3 is different,field3=amendedValue and field3=Unknown) into one mv field and then takes the first non "unknown" value for it.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Nov 2013 20:09:16 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2013-11-12T20:09:16Z</dc:date>
    <item>
      <title>lose one event if another one exists using dedup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138107#M37883</link>
      <description>&lt;P&gt;Hi Guys&lt;/P&gt;

&lt;P&gt;I am trying to automatically create a lookup table based on results from searches, part of the search will be to feed results back in from the previously generated lookup, something like this:&lt;/P&gt;

&lt;P&gt;search for some stuff | append [previousoutput.csv] |eval field3=if(is null(field3),"unknown",field3)&lt;/P&gt;

&lt;P&gt;This gets me so far and gives me results like:&lt;/P&gt;

&lt;P&gt;field1,field2,field3&lt;BR /&gt;
hannah,green,banana&lt;BR /&gt;
clive,red,unknown&lt;BR /&gt;
hannah,green,unknown&lt;/P&gt;

&lt;P&gt;This is where i am coming unstuck, i want the output lookup i generate off of the back of this to be reduplicated, 1 entry per user, but i only want to keep the amended version of field 3 if it exists, if an amended version of field 3 does not exist then i would like to populate the output with unknown, so my output csv would look like:&lt;/P&gt;

&lt;P&gt;field1,field2,field3&lt;BR /&gt;
hannah,green,banana&lt;BR /&gt;
clive,red,unknown&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Darren&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2013 09:51:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138107#M37883</guid>
      <dc:creator>darrend</dc:creator>
      <dc:date>2013-11-12T09:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: lose one event if another one exists using dedup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138108#M37884</link>
      <description>&lt;P&gt;Well, dedup? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | dedup field1 field2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Nov 2013 10:58:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138108#M37884</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-11-12T10:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: lose one event if another one exists using dedup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138109#M37885</link>
      <description>&lt;P&gt;That's what i originally tried, but with that approach there is no guarantee that you won't end up with:&lt;/P&gt;

&lt;P&gt;field1,field2,field3&lt;BR /&gt;
hannah,green,unknown&lt;BR /&gt;
clive,red,unknown&lt;/P&gt;

&lt;P&gt;I may not of worded my original question very well, but i need to guarantee that the alternate value gets kept if the alternate and the "unknown" values both exist.  I cannot do a sort as the alternate value will become a user controlled free text field in my app.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2013 11:15:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138109#M37885</guid>
      <dc:creator>darrend</dc:creator>
      <dc:date>2013-11-12T11:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: lose one event if another one exists using dedup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138110#M37886</link>
      <description>&lt;P&gt;Try following (assuming we get only two duplicate entries, one with amended value and one with "Unknown")&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search for some stuff | append [previousoutput.csv] |eval field3=if(is null(field3),"unknown",field3)
 | dedup field1, field2, field3| mvcombine field3 delim="," |eval val1=mvindex(field3,0) | eval val2=mvindex(field3,1) | eval field3=case(val1="Unknown" AND isnotnull(val2), val2, 1=1,val1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This combines field3 for duplicate values for field1 and field2 (field3 is different,field3=amendedValue and field3=Unknown) into one mv field and then takes the first non "unknown" value for it.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2013 20:09:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138110#M37886</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-11-12T20:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: lose one event if another one exists using dedup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138111#M37887</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;yourstuff | eval field3=if(isnull(field3),"zzzzzzzz",field3) | sort limit=0 field3 | dedup keepempty=t field3 | eval field3=if((field3)="zzzzzzzz","unknown",field3)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Feb 2015 16:48:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/lose-one-event-if-another-one-exists-using-dedup/m-p/138111#M37887</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2015-02-11T16:48:13Z</dc:date>
    </item>
  </channel>
</rss>

