<?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: How to sort date field year wise (which is in this format - ex :  Jan-2015) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241746#M175884</link>
    <description>&lt;P&gt;While displaying I would still want to use the expanded month name rather than 01, 02. Any idea on that?&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jan 2017 06:17:51 GMT</pubDate>
    <dc:creator>lakshmisri</dc:creator>
    <dc:date>2017-01-30T06:17:51Z</dc:date>
    <item>
      <title>How to sort date field year wise (which is in this format - ex :  Jan-2015)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241743#M175881</link>
      <description>&lt;P&gt;this is my query:&lt;/P&gt;

&lt;P&gt;|index = *&lt;BR /&gt;
count(search) AS "total_count" SPLITROW Test_ID SPLITROW R_S_Me SPLITROW Set SPLITROW Created_Date &lt;BR /&gt;
| eval targ_met = if(R_S_Me="Y", 1, if (R_S_Me="N", 0,-1))&lt;BR /&gt;&lt;BR /&gt;
| eval resp_per = ((targ_met/total_count)*100) &lt;BR /&gt;
 | eval _time = strftime(strptime("01-".'Created_Date', "%d-%b-%Y"),"%b%Y")&lt;BR /&gt;
| chart avg(resp_per) as "Response Metric" by Set, _time&lt;/P&gt;

&lt;P&gt;Results is in this format:&lt;/P&gt;

&lt;P&gt;Set    dec-2015 Feb-2016 Jan-2015 &lt;BR /&gt;
Set1     1            2               3&lt;BR /&gt;
Set2      1          2                3&lt;BR /&gt;
set3      1          2               3&lt;/P&gt;

&lt;P&gt;i am not able to sort the date as first Jan-2015 and then as Dec-2015 , here it is sorting alphabetical order .&lt;BR /&gt;
Any way to get in date format ?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:28:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241743#M175881</guid>
      <dc:creator>rijinc</dc:creator>
      <dc:date>2020-09-29T12:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort date field year wise (which is in this format - ex :  Jan-2015)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241744#M175882</link>
      <description>&lt;P&gt;In general, Splunk does not really make it easy to let you sort columns/fields in arbitrary ways. Splunk pretty much always want to sort columns/fields in ASCII order.&lt;/P&gt;

&lt;P&gt;So, the easiest solution is to use the numeric versions of the year/month, e.g., 2016-01, 2016-02, etc. That way you can do something like &lt;CODE&gt;| fields Set *&lt;/CODE&gt; in your query and the column names will be sorted in chronological order from left to right.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 14:08:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241744#M175882</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2017-01-18T14:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort date field year wise (which is in this format - ex :  Jan-2015)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241745#M175883</link>
      <description>&lt;P&gt;So you would change your eval to this&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eval _time = strftime(strptime("01-".'Created_Date', "%d-%b-%Y"),"%Y-%m")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 14:10:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241745#M175883</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2017-01-18T14:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort date field year wise (which is in this format - ex :  Jan-2015)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241746#M175884</link>
      <description>&lt;P&gt;While displaying I would still want to use the expanded month name rather than 01, 02. Any idea on that?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 06:17:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241746#M175884</guid>
      <dc:creator>lakshmisri</dc:creator>
      <dc:date>2017-01-30T06:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort date field year wise (which is in this format - ex :  Jan-2015)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241747#M175885</link>
      <description>&lt;P&gt;You cannot do that without specifying the fieldnames in the explicit order you want using &lt;CODE&gt;fields&lt;/CODE&gt; or &lt;CODE&gt;table&lt;/CODE&gt;; however, I am pretty sure that will display empty values for any columns you include that don't have data.&lt;/P&gt;

&lt;P&gt;Like I said in my original answer, Splunk does not really make this kind of thing easy. You will find many other questions on Splunk Answers with the same kind of problem, with no consistent answers.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 11:24:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241747#M175885</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2017-01-30T11:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort date field year wise (which is in this format - ex :  Jan-2015)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241748#M175886</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| index = *
| stats count(search) AS "total_count" SPLITROW Test_ID SPLITROW R_S_Me SPLITROW Set SPLITROW Created_Date 
| eval targ_met = if(R_S_Me="Y", 1, if (R_S_Me="N", 0,-1)) 
| eval resp_per = ((targ_met/total_count)*100) 
| eval Month = strftime(strptime("01-".'Created_Date', "%d-%b-%Y"),"%b%Y")
| streamstats dc(Month) AS _serial
| eval Month = case((_serial==13),                 Month,
                    (_serial==12),           " " . Month,
                    (_serial==11),          "  " . Month,
                    (_serial==10),         "   " . Month,
                    (_serial==9),         "    " . Month,
                    (_serial==8),        "     " . Month,
                    (_serial==7),       "      " . Month,
                    (_serial==6),      "       " . Month,
                    (_serial==5),     "        " . Month,
                    (_serial==4),    "         " . Month,
                    (_serial==3),   "          " . Month,
                    (_serial==2),  "           " . Month,
                    (_serial==1), "            " . Month)
| chart avg(resp_per) as "Response Metric" OVER Set BY Month
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2017 06:11:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-date-field-year-wise-which-is-in-this-format-ex-Jan/m-p/241748#M175886</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-06T06:11:03Z</dc:date>
    </item>
  </channel>
</rss>

