Splunk Search

Single value from multiple values

renuka
Path Finder

renuka_0-1596095140908.png

In my data i am getting multiple dates for single id.i need only recent date for each date.how can i remove other dates.please refer screenshot

Thank you in advance

renuka

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

I can't see your field names, but I am assuming you are getting your results from a search terminating with something like 

| stats values(date) as dates by id

you should use

| stats latest(date) as date by id

but without seeing your search I can't give you a better response

Hope this points you in the right direction

 

View solution in original post

0 Karma

bowesmana
SplunkTrust
SplunkTrust

I can't see your field names, but I am assuming you are getting your results from a search terminating with something like 

| stats values(date) as dates by id

you should use

| stats latest(date) as date by id

but without seeing your search I can't give you a better response

Hope this points you in the right direction

 

0 Karma

renuka
Path Finder

Thank you so much

Stats latest(date) as date by id is giving the values what i need

0 Karma

renuka
Path Finder

renuka_0-1596095776632.png

 Thank you for reply,this is my search command and fields

 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

You may need to check that the Splunk _time field actually equates to the TC_D2_Execution_Date. If not, then you will need to to it slightly differently, by looking for the largest date, i.e. 

| eval t=strptime(TC_D2_Execution_Date, "%a %d %b %Y %H:%M:%S")
| stats max(t) as Date by "CRS_Customer Requirement Identifier"
| eval Date=strftime(Date, "%a %d %b %Y %H:%M:%S")
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...