<?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: Table data sort behaviour in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60915#M15000</link>
    <description>&lt;P&gt;See if it works this way&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;somesearch&lt;BR /&gt;
| eval Month=relative_time(_time, "@mon")&lt;BR /&gt;
| some stats here&lt;BR /&gt;
| fieldformat Month = strftime(Month,"%d/%b/%y")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I think the rename confuses fieldformat, and the field name with spaces in it may also confuse it.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Sep 2012 09:22:14 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2012-09-19T09:22:14Z</dc:date>
    <item>
      <title>Table data sort behaviour</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60912#M14997</link>
      <description>&lt;P&gt;I have a search that outputs a table similar to the following.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Month starting  count
1-Sep-11    21424533
1-Oct-11    23025589
1-Nov-11    23291731
1-Dec-11    22275910
1-Jan-12    24153686
1-Feb-12    22862810
1-Mar-12    19596371
1-Apr-12    22270415
1-May-12    20289422
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This table exhibits unexpected sort behaviour in the web interface (splunk v4.3.4)&lt;BR /&gt;
You can sort in both directions via the count column but if you then click on the month starting column it only sorts it in one direction. The tool tip icon changes direction however.&lt;/P&gt;

&lt;P&gt;I have tried changing the date format from timeformat="%d/%b/%y" to various different ones (even including the time ie. %d-%b-%y %h:%m:%s). &lt;BR /&gt;
The only thing that allows it to sortable as a user expects is to use epoch time. &lt;BR /&gt;
Is there any way that I can make this table sortable?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2012 05:45:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60912#M14997</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2012-09-17T05:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Table data sort behaviour</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60913#M14998</link>
      <description>&lt;P&gt;How did you get the "Month starting?"&lt;BR /&gt;&lt;BR /&gt;
If you did it like this: &lt;CODE&gt;eval "Month starting"=strftime(_time,"%d-%b-%y")&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;
then you should try &lt;CODE&gt;fieldformat&lt;/CODE&gt; instead: &lt;CODE&gt;fieldformat "Month starting"=strftime(_time,"%d-%b-%y")&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;
which &lt;EM&gt;should&lt;/EM&gt; make the field sort properly. Another alternative is to use two fields. I'll call them monthEpoch and monthStarting - they are both the same date, but one is formatted and one is not. Here is an example&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| bucket span=1d _time
| eval monthEpoch = _time
| stats count by monthEpoch
| eval monthStarting = strftime(monthEpoch,"%d-%b-%y")
| sort monthEpoch
| table monthStarting count
| rename monthStarting as "Month starting"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;HTH&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2012 07:22:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60913#M14998</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-09-17T07:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Table data sort behaviour</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60914#M14999</link>
      <description>&lt;P&gt;The month starting is created like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;somesearch
| eval Month=relative_time(_time, "@mon")
| some stats here
| convert timeformat="%d/%b/%y" ctime(Month) AS "Period Month Starting"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So my search snaps each result into a monthly block so that I can then nicely combine them together using a stats by Month.&lt;/P&gt;

&lt;P&gt;If i try and use fieldformat like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fieldformat "Period Month Starting"=strftime(Month,"%d-%b-%y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get no output what so ever.&lt;BR /&gt;
You eval line "eval monthStarting = strftime(monthEpoch,"%d-%b-%y")" does work but gives me the same "unsortable" results table.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2012 23:46:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60914#M14999</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2012-09-17T23:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Table data sort behaviour</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60915#M15000</link>
      <description>&lt;P&gt;See if it works this way&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;somesearch&lt;BR /&gt;
| eval Month=relative_time(_time, "@mon")&lt;BR /&gt;
| some stats here&lt;BR /&gt;
| fieldformat Month = strftime(Month,"%d/%b/%y")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I think the rename confuses fieldformat, and the field name with spaces in it may also confuse it.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2012 09:22:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60915#M15000</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-09-19T09:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Table data sort behaviour</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60916#M15001</link>
      <description>&lt;P&gt;Your right. That last one is the only one that will work properly.&lt;/P&gt;

&lt;P&gt;ie. fieldformat Month = strftime(Month,"%d/%b/%y")&lt;/P&gt;

&lt;P&gt;Excellent thanks again! It seems that any eval-ing/formatting/copying to a new field/with a rename totally breaks how it than sorts in the table.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2012 02:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-data-sort-behaviour/m-p/60916#M15001</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2012-09-20T02:13:00Z</dc:date>
    </item>
  </channel>
</rss>

