Splunk Search

Pickup the latest row of records.

ishugupta
Path Finder

acct_nbr event_stamp membership_fee Zip_Code
12345 2014-07-08-10.27.13.000000 0.00 222
12345 2014-07-07-12.03.03.000000 55.00 222
67890 2014-07-14-12.03.03.000000 45.00 444
67890 2014-07-11-10.27.13.000000 44.00 444
67890 2014-07-15-12.03.03.000000 45.00 444

In the above record , I want to pick up the latest account number and its corresponding membership fee and zip based on the event_stamp field . I am not sure how to pick them . Below is the output I want:

12345 2014-07-08-10.27.13.000000 0.00 222
67890 2014-07-15-12.03.03.000000 45.00 444

Of all the methods I have tried , I am able to pick the latest time stamp , but I am not able to pick all the corresponding records .

Tags (2)
0 Karma
1 Solution

strive
Influencer

Assuming that the records will be in same order as you have mentioned try this

your search | stats first(event_stamp) as event_stamp, first(membership_fee) as membership_fee, first(Zip_Code) as Zip_Code by acct_nbr

I used your data as CSV and see the output
alt text

View solution in original post

strive
Influencer

Assuming that the records will be in same order as you have mentioned try this

your search | stats first(event_stamp) as event_stamp, first(membership_fee) as membership_fee, first(Zip_Code) as Zip_Code by acct_nbr

I used your data as CSV and see the output
alt text

ishugupta
Path Finder

Thanks Strive... very simple and apt solution...I was beating all around the bush...

0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...