<?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: SPL To only Pull Last Event Per Month in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748285#M241977</link>
    <description>You could use dedup with sortby parameter, as I previously show.</description>
    <pubDate>Thu, 19 Jun 2025 04:36:51 GMT</pubDate>
    <dc:creator>isoutamo</dc:creator>
    <dc:date>2025-06-19T04:36:51Z</dc:date>
    <item>
      <title>SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748029#M241933</link>
      <description>&lt;P&gt;Looking for SPL that will give me the ID Cost by month, only grabbing the last event (_time) for that month.&amp;nbsp; Sample data below. I have a system that updates cost daily for the same ID. Looking for guidence before I venture down a wrong path. Sample data below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE width="835px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="416px"&gt;&lt;A href="https://stage.splunk.wdprapps.disney.com/en-US/app/wdpr_enterprise_monitoring/search?q=search%20index%3Dmain%20sourcetype%3Dairflow%3Adatabricks%0A%60%60%60%7C%20search%20Bapp_ID%20IN%20(%24tok_bappid%7Cs%24)%20AND%20account_name%20IN%20(%24tok_aws_account%7Cs%24)%20AND%20product_code%20IN%20(%24tok_product_code%7Cs%24)%20%0A%7C%20eval%20_time%20%3D%20strptime(bill_billing_period_start_date%2C%20%22%25Y-%25m-%25d%22)%20%60%60%60&amp;amp;display.page.search.mode=smart&amp;amp;dispatch.sample_ratio=1&amp;amp;workload_pool=&amp;amp;earliest=-4h%40m&amp;amp;latest=now&amp;amp;display.page.search.tab=events&amp;amp;display.general.type=events&amp;amp;sid=1750098381.490159_1CC9432D-EFB3-4833-B546-0FC89248C14D" target="_blank" rel="noopener"&gt;bill_date&lt;/A&gt;&lt;/TD&gt;&lt;TD width="116px"&gt;ID&lt;/TD&gt;&lt;TD width="116px"&gt;Cost&lt;/TD&gt;&lt;TD width="187px"&gt;_time&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="416px"&gt;6/1/25&lt;/TD&gt;&lt;TD width="116px"&gt;1&lt;/TD&gt;&lt;TD width="116px"&gt;1.24&lt;/TD&gt;&lt;TD width="187px"&gt;2025-06-16T12:42:41.282-04:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="416px"&gt;6/1/25&lt;/TD&gt;&lt;TD width="116px"&gt;1&lt;/TD&gt;&lt;TD width="116px"&gt;1.4&lt;/TD&gt;&lt;TD width="187px"&gt;2025-06-16T12:00:41.282-04:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="416px"&gt;5/1/25&lt;/TD&gt;&lt;TD width="116px"&gt;1&lt;/TD&gt;&lt;TD width="116px"&gt;2.5&lt;/TD&gt;&lt;TD width="187px"&gt;2025-06-15T12:42:41.282-04:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="416px"&gt;5/1/25&lt;/TD&gt;&lt;TD width="116px"&gt;1&lt;/TD&gt;&lt;TD width="116px"&gt;2.2&lt;/TD&gt;&lt;TD width="187px"&gt;2025-06-14T12:00:41.282-04:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="416px"&gt;5/1/25&lt;/TD&gt;&lt;TD width="116px"&gt;2&lt;/TD&gt;&lt;TD width="116px"&gt;3.2&lt;/TD&gt;&lt;TD width="187px"&gt;2025-06-14T12:42:41.282-04:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="416px"&gt;5/1/25&lt;/TD&gt;&lt;TD width="116px"&gt;2&lt;/TD&gt;&lt;TD width="116px"&gt;3.3&lt;/TD&gt;&lt;TD width="187px"&gt;2025-06-14T12:00:41.282-04:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="416px"&gt;3/1/25&lt;/TD&gt;&lt;TD width="116px"&gt;1&lt;/TD&gt;&lt;TD width="116px"&gt;4.4&lt;/TD&gt;&lt;TD width="187px"&gt;2025-06-13T12:42:41.282-04:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="416px"&gt;3/1/25&lt;/TD&gt;&lt;TD width="116px"&gt;1&lt;/TD&gt;&lt;TD width="116px"&gt;5&lt;/TD&gt;&lt;TD width="187px"&gt;2025-06-13T12:00:41.282-04:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="416px"&gt;3/1/25&lt;/TD&gt;&lt;TD width="116px"&gt;2&lt;/TD&gt;&lt;TD width="116px"&gt;6&lt;/TD&gt;&lt;TD width="187px"&gt;2025-06-13T12:42:41.282-04:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="416px"&gt;3/1/25&lt;/TD&gt;&lt;TD width="116px"&gt;2&lt;/TD&gt;&lt;TD width="116px"&gt;6.3&lt;/TD&gt;&lt;TD width="187px"&gt;2025-06-13T12:00:41.282-04:00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 16 Jun 2025 19:05:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748029#M241933</guid>
      <dc:creator>chrisboy68</dc:creator>
      <dc:date>2025-06-16T19:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748055#M241937</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/118310"&gt;@chrisboy68&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How about using the bin command to bucket into 1 month blocks, then dedup on _time, or take first(fields) such as:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main 
| bin _time span=1month
| dedup _time
| table bill_date ID Cost _time&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main 
| bin _time span=1month
| stats first(bill_date) as bill_date, first(ID) as ID, first(Cost) as Cost by _time&lt;/LI-CODE&gt;&lt;P&gt;Or you could even look at timechart if useful.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jun 2025 23:10:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748055#M241937</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-06-16T23:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748063#M241940</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/118310"&gt;@chrisboy68&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want the latest cost for each ID per month,&lt;/P&gt;&lt;P&gt;try this,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;index=main&lt;BR /&gt;| bin _time span=1mon&lt;BR /&gt;| stats latest(Cost) as Cost latest(bill_date) as bill_date latest(_time) as _time by ID _time&lt;BR /&gt;| table bill_date ID Cost _time&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2025 04:24:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748063#M241940</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-06-17T04:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748108#M241953</link>
      <description>&lt;P&gt;Thanks, but that is still not working. Its only grabbing the very first ID. The data will have many IDs to one bill_date to multiple event times/_time.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2025 13:33:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748108#M241953</guid>
      <dc:creator>chrisboy68</dc:creator>
      <dc:date>2025-06-17T13:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748110#M241954</link>
      <description>&lt;P&gt;Have you try dedup with sortby? And of course you should use bin with a new column like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main 
| bin _time as time span=1month
| dedup time sortby _time
| table bill_date ID Cost _time&lt;/LI-CODE&gt;&lt;P&gt;In that way it should take only one event per month. Modifying sort order it will be first or last event in month.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2025 13:49:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748110#M241954</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2025-06-17T13:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748184#M241956</link>
      <description>&lt;P&gt;First, the mock data doesn't seem to agree with "update cost daily". &amp;nbsp;Wouldn't the following make more sense?&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;bill_date&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Cost&lt;/TD&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/1/25&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1.24&lt;/TD&gt;&lt;TD&gt;2025-06-16 09:42:41.282&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/1/25&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1.4&lt;/TD&gt;&lt;TD&gt;2025-06-06 09:00:41.282&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5/1/25&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2.5&lt;/TD&gt;&lt;TD&gt;2025-05-25 09:42:41.282&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5/1/25&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2.2&lt;/TD&gt;&lt;TD&gt;2025-05-15 09:00:41.282&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5/1/25&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3.2&lt;/TD&gt;&lt;TD&gt;2025-05-14 09:42:41.282&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5/1/25&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3.3&lt;/TD&gt;&lt;TD&gt;2025-05-04 09:00:41.282&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/1/25&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4.4&lt;/TD&gt;&lt;TD&gt;2025-03-23 09:42:41.282&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/1/25&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;2025-03-18 09:00:41.282&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/1/25&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;2025-03-13 09:42:41.282&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/1/25&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;6.3&lt;/TD&gt;&lt;TD&gt;2025-03-03 08:00:41.282&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Secondly, when you say latest event "of the month", I assume "month" can be represented by bill_date. &amp;nbsp;Is this correct?&lt;/P&gt;&lt;P&gt;This is the search you need:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats latest(Cost) as Cost by bill_date ID&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 18 Jun 2025 05:28:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748184#M241956</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-06-18T05:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748202#M241957</link>
      <description>&lt;P&gt;You need to be a bit more precise about the requirements but generally it indeed looks like a case for proper sorting data and using dedup so that it only "catches" the first result for any given combination of fields.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 08:55:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748202#M241957</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-06-18T08:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748250#M241969</link>
      <description>&lt;P&gt;Ok, let me try to get some better sample data. Believe I have it here. While this is only one ID, the data has multiple IDs, and its spans multiple months.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=1 | eval ID="10001", _time=strptime("2025-06-01 08:00:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-06-01", cost=100.50, code="product1" | append [| makeresults | eval ID="10001", _time=strptime("2025-06-01 10:15:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-06-01", cost=120.75, code="product2"] | append [| makeresults | eval ID="10001", _time=strptime("2025-06-01 13:30:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-06-01", cost=140.00, code="product3"] | append [| makeresults | eval ID="10001", _time=strptime("2025-06-02 10:15:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-06-01", cost=130.75, code="product2"] | append [| makeresults | eval ID="10001", _time=strptime("2025-06-02 13:30:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-06-01", cost=150.00, code="product3"] | append [| makeresults | eval ID="10001", _time=strptime("2025-06-01 08:10:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-06-01", cost=102.50, code="product1"] | append [| makeresults | eval ID="10001", _time=strptime("2025-06-01 10:15:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-06-01", cost=125.75, code="product2"] | append [| makeresults | eval ID="10001", _time=strptime("2025-06-01 13:30:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-06-01", cost=145.00, code="product3"] | append [| makeresults | eval ID="10001", _time=strptime("2025-06-02 10:15:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-06-01", cost=135.75, code="product2"] | append [| makeresults | eval ID="10001", _time=strptime("2025-06-02 13:30:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-06-01", cost=155.00, code="product3"] | append [| makeresults | eval ID="10001", _time=strptime("2025-05-01 10:15:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-05-01", cost=125.75, code="product2"] | append [| makeresults | eval ID="10001", _time=strptime("2025-05-01 13:30:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-05-01", cost=145.00, code="product3"] | append [| makeresults | eval ID="10001", _time=strptime("2025-05-02 10:15:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-05-01", cost=135.75, code="product2"] | append [| makeresults | eval ID="10001", _time=strptime("2025-05-02 13:30:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-05-01", cost=155.00, code="product3"] | append [| makeresults | eval ID="10001", _time=strptime("2025-05-01 10:15:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-05-01", cost=120.75, code="product2"] | append [| makeresults | eval ID="10001", _time=strptime("2025-05-02 13:30:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-05-01", cost=140.00, code="product3"] | append [| makeresults | eval ID="10001", _time=strptime("2025-05-02 10:15:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-05-01", cost=130.75, code="product2"] | append [| makeresults | eval ID="10001", _time=strptime("2025-05-02 13:30:00", "%Y-%m-%d %H:%M:%S"), billing_date="2025-05-01", cost=150.00, code="product3"]&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 18 Jun 2025 15:02:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748250#M241969</guid>
      <dc:creator>chrisboy68</dc:creator>
      <dc:date>2025-06-18T15:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748273#M241972</link>
      <description>&lt;P&gt;Oooompf. That's a bit ineffective way of creating mock data. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'd go with makeresults format=csv data=...&lt;/P&gt;&lt;P&gt;But to the point.&lt;/P&gt;&lt;P&gt;Assuming you want the first (or last - it's just a matter of proper sorting) cost value for each ID daily&lt;/P&gt;&lt;PRE&gt;| sort - _time&lt;BR /&gt;``` this way you'll get the latest value for each day because it will be the first one```&lt;BR /&gt;| bin _time span=1d&lt;BR /&gt;``` this will "group" your data by day ```&lt;BR /&gt;| dedup _time ID&lt;BR /&gt;``` and this will only leave first event for each combination of _time and ID```&lt;/PRE&gt;&lt;P&gt;You can of course sort the other way (actually the reverse chronological order is the default one; it's just included here for the solution to be as explicitly stated as possible) if you want first values daily, not last ones. And can do dedup over more fields (to get the values by code as well as date and ID, for example).&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 20:15:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748273#M241972</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-06-18T20:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748283#M241975</link>
      <description>&lt;P&gt;Is this the result&amp;nbsp;you are looking for?&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;billing_date&lt;/TD&gt;&lt;TD&gt;code&lt;/TD&gt;&lt;TD&gt;latest(cost)&lt;/TD&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;2025-05-01&lt;/TD&gt;&lt;TD&gt;product2&lt;/TD&gt;&lt;TD&gt;135.75&lt;/TD&gt;&lt;TD&gt;2025-05-02 10:15:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;2025-05-01&lt;/TD&gt;&lt;TD&gt;product3&lt;/TD&gt;&lt;TD&gt;155.00&lt;/TD&gt;&lt;TD&gt;2025-05-02 13:30:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;2025-06-01&lt;/TD&gt;&lt;TD&gt;product1&lt;/TD&gt;&lt;TD&gt;102.50&lt;/TD&gt;&lt;TD&gt;2025-06-01 08:10:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;2025-06-01&lt;/TD&gt;&lt;TD&gt;product2&lt;/TD&gt;&lt;TD&gt;130.75&lt;/TD&gt;&lt;TD&gt;2025-06-02 10:15:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;2025-06-01&lt;/TD&gt;&lt;TD&gt;product3&lt;/TD&gt;&lt;TD&gt;150.00&lt;/TD&gt;&lt;TD&gt;2025-06-02 13:30:00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;dedup with perfect sort as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;suggests should work. &amp;nbsp;Another way is to simply use stats as I originally suggested:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats latest(cost) max(_time) as _time by ID billing_date code&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2025 02:00:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748283#M241975</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-06-19T02:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748285#M241977</link>
      <description>You could use dedup with sortby parameter, as I previously show.</description>
      <pubDate>Thu, 19 Jun 2025 04:36:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748285#M241977</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2025-06-19T04:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748370#M241981</link>
      <description>&lt;P&gt;Stats should be way faster and efficient but it won't give you other fields. So whether it's stats or dedup depends on the desired results.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2025 18:37:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748370#M241981</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-06-19T18:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748371#M241982</link>
      <description>&lt;P&gt;Yup. You're right. I keep forgetting about that option. For me it's clearer to do those two operations separately. I wonder though whether there is a performance difference.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2025 18:42:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748371#M241982</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-06-19T18:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748456#M241995</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/118310"&gt;@chrisboy68&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;There are lots of options presented, but combining&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;'s response with a conversion from bill_date to year and month gives the output closest to "ID Cost by month":&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| makeresults format=csv data="bill_date,ID,Cost,_time
6/1/25,1,1.24,2025-06-16T12:42:41.282-04:00
6/1/25,1,1.4,2025-06-16T12:00:41.282-04:00
5/1/25,1,2.5,2025-06-15T12:42:41.282-04:00
5/1/25,1,2.2,2025-06-14T12:00:41.282-04:00
5/1/25,2,3.2,2025-06-14T12:42:41.282-04:00
5/1/25,2,3.3,2025-06-14T12:00:41.282-04:00
3/1/25,1,4.4,2025-06-13T12:42:41.282-04:00
3/1/25,1,5,2025-06-13T12:00:41.282-04:00
3/1/25,2,6,2025-06-13T12:42:41.282-04:00
3/1/25,2,6.3,2025-06-13T12:00:41.282-04:00"
| eval _time=strptime(_time, "%FT%T.%N%z")
``` end test data ```
``` assuming month/day/year for bill_date ```
| eval Month=strftime(strptime(bill_date, "%m/%e/%y"), "%Y-%m")
| stats latest(Cost) as Cost by Month ID&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;Month     ID   Cost
-----     --   ----
2025-03   1     4.4
2025-03   2       6
2025-05   1     2.5
2025-05   2     3.2
2025-06   1    1.24&lt;/LI-CODE&gt;&lt;P&gt;You can alternatively use chart, xyseries, etc. to pivot the results:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| chart latest(Cost) over ID by Month&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;ID   2025-03   2025-05   2025-06
--   -------   -------   -------
1        4.4       2.5      1.24
2          6       3.2&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 21 Jun 2025 15:38:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748456#M241995</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2025-06-21T15:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: SPL To only Pull Last Event Per Month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748733#M242049</link>
      <description>&lt;P&gt;Thanks. Believe I got it. What tripped me up, is I didn't realize latest could be used for non-time based fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2025 17:05:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-To-only-Pull-Last-Event-Per-Month/m-p/748733#M242049</guid>
      <dc:creator>chrisboy68</dc:creator>
      <dc:date>2025-06-25T17:05:23Z</dc:date>
    </item>
  </channel>
</rss>

