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!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...