<?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: Can you help me with dedup and date field. How to get the latest record? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421777#M121127</link>
    <description>&lt;P&gt;So it uses the timestamp of the EVENT... or the data contents of that FIELD (im my case it is a data/time field). That is an important distinction for me to understand.&lt;/P&gt;

&lt;P&gt;Thank You!&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jan 2019 22:59:48 GMT</pubDate>
    <dc:creator>joesrepsolc</dc:creator>
    <dc:date>2019-01-22T22:59:48Z</dc:date>
    <item>
      <title>Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421770#M121120</link>
      <description>&lt;P&gt;I figured out how to use the dedup command by the user (see example below) but I still want to get the latest record based on date per user. I've been fumbling around and am obviously missing something with the dedup command or additional commands to achieve this.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;STARTING WITH:&lt;/STRONG&gt;&lt;BR /&gt;
USER    STATUS      DATE&lt;BR /&gt;
A      Active       1/20/2019&lt;BR /&gt;
A   Disabled    10/15/2017&lt;BR /&gt;
A   Active      1/22/2015&lt;BR /&gt;
B   Leave       7/01/2016&lt;BR /&gt;
B   Active      4/01/2013&lt;BR /&gt;
C   Active      6/26/2018&lt;BR /&gt;
D   Active      7/04/2017&lt;BR /&gt;
E   Terminated  6/30/2018&lt;BR /&gt;
E   Active      5/01/2015&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;WANT THIS BACK (1 row, then latest "date" per user):&lt;/STRONG&gt;&lt;BR /&gt;
USER    STATUS      DATE&lt;BR /&gt;
A   Active      1/20/2019&lt;BR /&gt;
B   Leave       7/01/2016&lt;BR /&gt;
C   Active      6/26/2018&lt;BR /&gt;
D   Active      7/04/2017&lt;BR /&gt;
E   Terminated  6/30/2018&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 20:45:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421770#M121120</guid>
      <dc:creator>joesrepsolc</dc:creator>
      <dc:date>2019-01-22T20:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421771#M121121</link>
      <description>&lt;P&gt;I must be missing something in your question because &lt;CODE&gt;dedup&lt;/CODE&gt; takes the most recent record for each unique user (in your case).  What are you seeing that is different from that?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 21:11:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421771#M121121</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-01-22T21:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421772#M121122</link>
      <description>&lt;P&gt;Can you please paste your current search query.&lt;/P&gt;

&lt;P&gt;Instead of dedup you could use&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourquery&amp;gt;|stats latest(Date) as Date , latest(Status) as Status by User
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jan 2019 21:17:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421772#M121122</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-01-22T21:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421773#M121123</link>
      <description>&lt;P&gt;index=indexname&lt;BR /&gt;
|dedup user date&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 22:10:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421773#M121123</guid>
      <dc:creator>joesrepsolc</dc:creator>
      <dc:date>2019-01-22T22:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421774#M121124</link>
      <description>&lt;P&gt;I run that as my search, and I get unique user and unique dates (but still multiple records). If there are multiple edits made on the same day I'm not sure which one is winning. So I want to specify the most recent (by date). Just confusing myself on the search part&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 22:12:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421774#M121124</guid>
      <dc:creator>joesrepsolc</dc:creator>
      <dc:date>2019-01-22T22:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421775#M121125</link>
      <description>&lt;P&gt;trying this now... wasn't sure I could solve my problem without the use of "dedup". Interesting... running tests now.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 22:15:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421775#M121125</guid>
      <dc:creator>joesrepsolc</dc:creator>
      <dc:date>2019-01-22T22:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421776#M121126</link>
      <description>&lt;P&gt;@joesrepsolc When you use latest it will give you the latest of that field( here date and status) based on the latest timestamp of that event and that would ideally be the most recent one for that user.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 22:36:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421776#M121126</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-01-22T22:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421777#M121127</link>
      <description>&lt;P&gt;So it uses the timestamp of the EVENT... or the data contents of that FIELD (im my case it is a data/time field). That is an important distinction for me to understand.&lt;/P&gt;

&lt;P&gt;Thank You!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 22:59:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421777#M121127</guid>
      <dc:creator>joesrepsolc</dc:creator>
      <dc:date>2019-01-22T22:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421778#M121128</link>
      <description>&lt;P&gt;latest uses timestamp , it will give you most recent date and status based on timestamp for a user.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 23:03:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421778#M121128</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-01-22T23:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421779#M121129</link>
      <description>&lt;P&gt;hello there,&lt;/P&gt;

&lt;P&gt;here is solution without &lt;CODE&gt;| dedup&lt;/CODE&gt;. imho &lt;CODE&gt;| dedup&lt;/CODE&gt; is not ideal for your challenge, more explanation at docs here:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Dedup"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Dedup&lt;/A&gt;&lt;BR /&gt;
and especially this: &lt;CODE&gt;"... Events returned by dedup are based on search order. For historical searches, the most recent events are searched first ... "&lt;/CODE&gt;&lt;BR /&gt;
which in your case, you would like to dedup based on value of a field, not order returned&lt;/P&gt;

&lt;P&gt;run this search anywhere:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1
| eval data = "A Active 1/20/2019;A Disabled 10/15/2017;A Active 1/22/2015;B Leave 7/01/2016;B Active 4/01/2013;C Active 6/26/2018;D Active 7/04/2017;E Terminated 6/30/2018;E Active 5/01/2015"
| makemv delim=";" data
| mvexpand data
| rex field=data "(?&amp;lt;USER&amp;gt;[^\s]+)\s(?&amp;lt;STATUS&amp;gt;[^\s]+)\s(?&amp;lt;DATE&amp;gt;[^\s]+)"
| table USER STATUS DATE 
| rename COMMENT as "above generates fake results, belew is your solution"
| rename COMMENT as "here i will use epoch time and the stats max() function to capture last event"
| eval DATE_EPOCH = strptime(DATE, "%m/%d/%Y")
| stats max(DATE_EPOCH) as "Last Status Time" by USER
| eval "Last Status Time" = strftime('Last Status Time', "%m/%d/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;see screenshot:&lt;/P&gt;

&lt;P&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/6433i8164366664516FBC/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;hope it helps&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 01:59:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421779#M121129</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-01-23T01:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421780#M121130</link>
      <description>&lt;P&gt;HI joesrepsolc, &lt;/P&gt;

&lt;P&gt;Given your list of names with associated dates, you want a list of users with the most recent date returned.&lt;/P&gt;

&lt;P&gt;Based on that, I would suggest something like this:&lt;BR /&gt;
&lt;CODE&gt;index=main | dedup USER | stats latest(DATE) by USER&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps! &lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 02:44:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421780#M121130</guid>
      <dc:creator>ellothere</dc:creator>
      <dc:date>2019-01-23T02:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421781#M121131</link>
      <description>&lt;P&gt;you are correct about the dedup function not really fitting what I'm trying to do. This was surely a setback in me figuring this out.&lt;/P&gt;

&lt;P&gt;You example is TREMENDOUS. Fake sample data... i didn't even know that was possible. Awesome. Studying your example code (and REGEX) now. Very helpful. Thank you for your response.&lt;/P&gt;

&lt;P&gt;Wow'd&lt;/P&gt;

&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 17:10:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421781#M121131</guid>
      <dc:creator>joesrepsolc</dc:creator>
      <dc:date>2019-01-23T17:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421782#M121132</link>
      <description>&lt;P&gt;Thank You.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 17:10:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421782#M121132</guid>
      <dc:creator>joesrepsolc</dc:creator>
      <dc:date>2019-01-23T17:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421783#M121133</link>
      <description>&lt;P&gt;@joesrepsolc youre very welcome&lt;BR /&gt;
if it answers te question, kindly accept the answer so others will know it worked for you&lt;BR /&gt;
you are welcome to upvote any comments that you ind helpful as well&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 20:27:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421783#M121133</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-01-23T20:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421784#M121134</link>
      <description>&lt;P&gt;You just need to sort by DATE first, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Base Search Here 
| eval _time = strptime(DATE, "%m/%d/%Y")
| sort 0 - _time
| dedup USER
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Feb 2019 01:10:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421784#M121134</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-14T01:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421785#M121135</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;

&lt;P&gt;Is your suggestion really any different than the previous comment? Just trying to understand the difference (if any). So DEDUP inherently sorts by the event time of the record, so if I "| DEDUP USER" that really should be all I need right to show the most recent log event, per user, and only get (1) record per user right?&lt;/P&gt;

&lt;P&gt;Thanks. Joe&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 15:52:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421785#M121135</guid>
      <dc:creator>joesrepsolc</dc:creator>
      <dc:date>2019-02-14T15:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421786#M121136</link>
      <description>&lt;P&gt;You are mistaken: &lt;CODE&gt;dedup&lt;/CODE&gt; does NOT sort under any circumstances.  It just walks from the top to the bottom keeping the first one that it finds.  Yes, my answer is different and will work.  Just try it.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 21:03:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421786#M121136</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-14T21:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421787#M121137</link>
      <description>&lt;P&gt;Thank you woodcock... as usual, you are correct. dedup simply returns the top row based on the field you specify. I mistakenly took that as sorting by most recent (_time)... but that is not the case. Good to know.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 16:48:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421787#M121137</guid>
      <dc:creator>joesrepsolc</dc:creator>
      <dc:date>2019-02-15T16:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with dedup and date field. How to get the latest record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421788#M121138</link>
      <description>&lt;P&gt;@joesrepsolc Is your problem resolved?  If so, please accept an answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 14:23:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-dedup-and-date-field-How-to-get-the-latest/m-p/421788#M121138</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-02-27T14:23:35Z</dc:date>
    </item>
  </channel>
</rss>

