<?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: How to get compare latest values across an index with a lookup and display the latest? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741600#M240646</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/246885"&gt;@hummingbird81&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;UL&gt;&lt;LI&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Why the &lt;/SPAN&gt;&lt;SPAN class=""&gt;if()&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;: To handle cases where &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;_time&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt; might be missing in the CSV, using &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;end_Date&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt; as a fallback.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Why &lt;/SPAN&gt;&lt;SPAN class=""&gt;strptime&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;: To convert &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;end_Date&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt; from a string to a numeric epoch timestamp for proper sorting.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Why in &lt;/SPAN&gt;&lt;SPAN class=""&gt;append&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;: Because the CSV’s timestamp situation is less certain than Okta’s&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 12 Mar 2025 15:26:48 GMT</pubDate>
    <dc:creator>kiran_panchavat</dc:creator>
    <dc:date>2025-03-12T15:26:48Z</dc:date>
    <item>
      <title>How to get compare latest values across an index with a lookup and display the latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741562#M240641</link>
      <description>&lt;P&gt;Hi All, looking for some advice as in how to take the latest values from 2 datasets .&amp;nbsp; We have a base search that pulls user details like name, start_date, end_date, title, location etc from an index =okta.&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;name&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;start_date&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;end_date&lt;/TD&gt;&lt;TD width="12.5%" height="25px"&gt;title&lt;/TD&gt;&lt;TD width="12.5%"&gt;user_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;John Smith&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;2021-06-28T23:59:59.00+05:30&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;2025-06-28T23:59:59.00+05:30&lt;/TD&gt;&lt;TD width="12.5%" height="25px"&gt;Consultant&lt;/TD&gt;&lt;TD width="12.5%"&gt;001&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;The above index has the most current data of a user.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Next we have another master lookup file (identities.csv)&amp;nbsp; where we maintain all user details from past few years.&amp;nbsp; &amp;nbsp;This master lookup also contains same fields as the above index.&amp;nbsp; For example:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;name&lt;/TD&gt;&lt;TD width="25%"&gt;start_date&lt;/TD&gt;&lt;TD width="25%"&gt;end_date&lt;/TD&gt;&lt;TD width="12.5%"&gt;title&lt;/TD&gt;&lt;TD width="12.5%"&gt;user_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;John Smith&lt;/TD&gt;&lt;TD width="25%"&gt;2021-06-28T23:59:59.00+05:30&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;2022&lt;/STRONG&gt;-06-28T23:59:59.00+05:30&lt;/TD&gt;&lt;TD width="12.5%"&gt;Administrator&lt;/TD&gt;&lt;TD width="12.5%"&gt;001&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Notice the &lt;STRONG&gt;end _date&lt;/STRONG&gt; and &lt;STRONG&gt;title&lt;/STRONG&gt; are different in the lookup.&lt;BR /&gt;&lt;BR /&gt;Below is our current search that compares the 2 datasets.&amp;nbsp; We want it to update the date fields or any other field&amp;nbsp; whichever is the latest&amp;nbsp; but at the moment it does NOT update the fields even if any field like end_date or title is modified under index.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=okta 
stats latest(_time) as _time,  values(profile.title) as title, values(profile.email) as email, values(profile.startDate) as start_Date,values(profile.endDate) as end_Date, values(profile.Name) as Name by user_id
| append [|inputlookup identities.csv]
|stats latest(_time) as _time,  latest(profile.title) as title, latest(profile.email) as email, latest(profile.startDate) as start_Date,latest(profile.endDate) as end_Date, latest(profile.Name) as Name by user_id
| table Name title start_date end_date user_id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Running the above query still shows the old info which has the old end_date and title&amp;nbsp; even though i am using &lt;STRONG&gt;|stats latest()&amp;nbsp; .&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt; Pls advise how to retrieve the latest be it date format or be it string format which is "title"&lt;/P&gt;&lt;TABLE border="1" width="777px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="193.703px"&gt;name&lt;/TD&gt;&lt;TD width="194.172px"&gt;start_date&lt;/TD&gt;&lt;TD width="194.172px"&gt;end_date&lt;/TD&gt;&lt;TD width="193.953px"&gt;title&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="193.703px"&gt;John Smith&lt;/TD&gt;&lt;TD width="194.172px"&gt;2021-06-28T23:59:59.00+05:30&lt;/TD&gt;&lt;TD width="194.172px"&gt;&lt;STRONG&gt;2022&lt;/STRONG&gt;-06-28T23:59:59.00+05:30&lt;/TD&gt;&lt;TD width="193.953px"&gt;Administrator&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 12 Mar 2025 12:00:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741562#M240641</guid>
      <dc:creator>hummingbird81</dc:creator>
      <dc:date>2025-03-12T12:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to get compare latest values across an index with a lookup and display the latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741566#M240642</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/246885"&gt;@hummingbird81&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested this using makeresults with dummy data. Copy and paste this query into your Splunk search bar to run it. It doesn’t depend on your actual index or CSV, so it's safe for testing.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Dummy data:-&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;| makeresults 
| eval _time=strptime("2025-03-01T12:00:00.00+05:30", "%Y-%m-%dT%H:%M:%S.%2Q%z"), 
       user_id="001", 
       Name="John Smith", 
       title="Consultant", 
       email="john.smith@example.com", 
       start_Date="2021-06-28T23:59:59.00+05:30", 
       end_Date="2025-06-28T23:59:59.00+05:30", 
       source="okta", 
       mod_time=_time
| fields user_id, Name, title, email, start_Date, end_Date, mod_time, source
| append [
    | makeresults 
    | eval _time=strptime("2022-06-01T12:00:00.00+05:30", "%Y-%m-%dT%H:%M:%S.%2Q%z"), 
           user_id="001", 
           Name="John Smith", 
           title="Administrator", 
           email="john.smith@example.com", 
           start_Date="2021-06-28T23:59:59.00+05:30", 
           end_Date="2022-06-28T23:59:59.00+05:30", 
           source="csv", 
           mod_time=if(isnull(_time), strptime(end_Date, "%Y-%m-%dT%H:%M:%S.%2Q%z"), _time)
    | fields user_id, Name, title, email, start_Date, end_Date, mod_time, source
]
| sort 0 -mod_time
| dedup user_id
| table Name, title, start_Date, end_Date, user_id&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kiran_panchavat_1-1741781556996.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/38136i4EC2FA3CEFA9469E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kiran_panchavat_1-1741781556996.png" alt="kiran_panchavat_1-1741781556996.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try this:-&lt;/P&gt;&lt;PRE&gt;index=okta 
| eval source="okta", mod_time=_time
| fields user_id, Name, title, email, start_Date, end_Date, mod_time, source
| append [ 
    | inputlookup identities.csv 
    | eval source="csv", mod_time=if(isnull(_time), strptime(end_Date, "%Y-%m-%dT%H:%M:%S.%2Q%z"), _time) 
    | fields user_id, Name, title, email, start_Date, end_Date, mod_time, source 
]
| sort 0 -mod_time  /* Sort by mod_time descending to prioritize latest */
| dedup user_id     /* Keep only the first (latest) record per user_id */
| table Name, title, start_Date, end_Date, user_id&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 14:31:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741566#M240642</guid>
      <dc:creator>kiran_panchavat</dc:creator>
      <dc:date>2025-03-12T14:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to get compare latest values across an index with a lookup and display the latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741592#M240643</link>
      <description>&lt;P&gt;Thank you so much. Let me test it out in detail but it looks promising.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 14:07:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741592#M240643</guid>
      <dc:creator>hummingbird81</dc:creator>
      <dc:date>2025-03-12T14:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get compare latest values across an index with a lookup and display the latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741596#M240644</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/246885"&gt;@hummingbird81&lt;/a&gt;&amp;nbsp;Sounds good! Please test it and let me know. If everything works fine, kindly accept the solution.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 14:32:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741596#M240644</guid>
      <dc:creator>kiran_panchavat</dc:creator>
      <dc:date>2025-03-12T14:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get compare latest values across an index with a lookup and display the latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741598#M240645</link>
      <description>&lt;P&gt;can you pls confirm why are you doing a " mod_time=if(isnull(_time), strptime(end_Date, "%Y-%m-%dT%H:%M:%S.%2Q%z"), _time)"&amp;nbsp; in the append portion ?&amp;nbsp; What is the need to do a strptime here ?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 15:16:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741598#M240645</guid>
      <dc:creator>hummingbird81</dc:creator>
      <dc:date>2025-03-12T15:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to get compare latest values across an index with a lookup and display the latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741600#M240646</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/246885"&gt;@hummingbird81&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;UL&gt;&lt;LI&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Why the &lt;/SPAN&gt;&lt;SPAN class=""&gt;if()&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;: To handle cases where &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;_time&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt; might be missing in the CSV, using &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;end_Date&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt; as a fallback.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Why &lt;/SPAN&gt;&lt;SPAN class=""&gt;strptime&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;: To convert &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;end_Date&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt; from a string to a numeric epoch timestamp for proper sorting.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Why in &lt;/SPAN&gt;&lt;SPAN class=""&gt;append&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;: Because the CSV’s timestamp situation is less certain than Okta’s&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 12 Mar 2025 15:26:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-compare-latest-values-across-an-index-with-a-lookup/m-p/741600#M240646</guid>
      <dc:creator>kiran_panchavat</dc:creator>
      <dc:date>2025-03-12T15:26:48Z</dc:date>
    </item>
  </channel>
</rss>

