Splunk Search

How to modify my search to sort date values in order to populate a check box form?

lchin
New Member

Hello, Splunk rookie here,

I have a field in my data set that shows a date (ie. 06/26/2016) which I have used to populate a checkbox form. Here is my search string:

index="cleanout_dash2" sourcetype="csv" ACTUAL_CO_DATE=*  | dedup ACTUAL_CO_DATE

I use the dedup command to get only unique values however those values appear in a random order. I have tried adding the sort command with no success. May I have the wrong syntax.

Thanks,

Lonnie

0 Karma
1 Solution

somesoni2
Revered Legend

This should do it. Right now doing sorting in ascending order. Change | sort sortfield with | sort -sortfield if you want descending order.

index="cleanout_dash2" sourcetype="csv" ACTUAL_CO_DATE=*  | dedup ACTUAL_CO_DATE | eval sortfield=strptime(ACTUAL_CO_DATE,"%m/%d/%Y") | sort sortfield | table ACTUAL_CO_DATE

View solution in original post

0 Karma

somesoni2
Revered Legend

This should do it. Right now doing sorting in ascending order. Change | sort sortfield with | sort -sortfield if you want descending order.

index="cleanout_dash2" sourcetype="csv" ACTUAL_CO_DATE=*  | dedup ACTUAL_CO_DATE | eval sortfield=strptime(ACTUAL_CO_DATE,"%m/%d/%Y") | sort sortfield | table ACTUAL_CO_DATE
0 Karma

lchin
New Member

Thanks so much that worked perfectly. I was screwing up the syntax in the eval command.

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...