<?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: sort  show wrong result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253798#M75973</link>
    <description>&lt;P&gt;it's because 01 is less than 17, I'd bet. Can you reformat the date to be Month/Day/Year? Or create a separate date field for Month/Day/Year that you sort by and then do a &lt;CODE&gt;fields - MDY&lt;/CODE&gt; to hide that field in the output?&lt;/P&gt;</description>
    <pubDate>Thu, 13 Oct 2016 17:06:53 GMT</pubDate>
    <dc:creator>cmerriman</dc:creator>
    <dc:date>2016-10-13T17:06:53Z</dc:date>
    <item>
      <title>sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253795#M75970</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I hope anyone can help me.&lt;/P&gt;

&lt;P&gt;My search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval epochtime=strptime(DATUM,"%d.%m.%Y") | eval datefield=strftime(epochtime,"%d.%m.%Y") | chart list(VOL_DDC_OUT) by datefield,host useother=f | tail 15 | sort datefield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I converted the string DATUM to a dateformat and I thought it will be handled as a dateformat, but it doesn't work correctly.&lt;/P&gt;

&lt;P&gt;Output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;01.10.2016  0   0    
17.09.2016  0   0   0
18.09.2016  0   0   0
19.09.2016  576     183     0
20.09.2016  0   0   0
21.09.2016  194     0   0
22.09.2016  317126  193     0
23.09.2016  30376   1127    0
24.09.2016  0   0   0
25.09.2016  0   0   0
26.09.2016  1725    18965   0
27.09.2016  21292   390     0
28.09.2016  26605   0   2895
29.09.2016  3324    21580   0
30.09.2016  85292   1352    0 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Why is the first date 1.10.2016? It should be the last one. It looks like that the field "datefield" isn't a dateformat.&lt;/P&gt;

&lt;P&gt;Can anybody help me that the sorting is working correctly.&lt;/P&gt;

&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2016 14:21:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253795#M75970</guid>
      <dc:creator>Paul1896</dc:creator>
      <dc:date>2016-10-13T14:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253796#M75971</link>
      <description>&lt;P&gt;Sort command works on datefield  field as a string so 01.10.2016 comes before 17.09.2016.&lt;BR /&gt;
Insert the sort command between the two eval commands and sort by epochtime.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe &lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2016 17:01:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253796#M75971</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-10-13T17:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253797#M75972</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;tail 15 | sort DATUM | eval epochtime=strptime(DATUM,"%d.%m.%Y") | eval datefield=strftime(epochtime,"%d.%m.%Y") | chart list(VOL_DDC_OUT) by datefield,host useother=f 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Oct 2016 17:03:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253797#M75972</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2016-10-13T17:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253798#M75973</link>
      <description>&lt;P&gt;it's because 01 is less than 17, I'd bet. Can you reformat the date to be Month/Day/Year? Or create a separate date field for Month/Day/Year that you sort by and then do a &lt;CODE&gt;fields - MDY&lt;/CODE&gt; to hide that field in the output?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2016 17:06:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253798#M75973</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2016-10-13T17:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253799#M75974</link>
      <description>&lt;P&gt;or create a separate field and convert DATNUM to an epoch field and just sort by that.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2016 17:07:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253799#M75974</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2016-10-13T17:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253800#M75975</link>
      <description>&lt;P&gt;You're correct.  The "datefield" field is not a date.  It's a string and it's being sorted correctly as a string.  The solution is to sort on a hidden integer.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval epochtime=strptime(DATUM,"%d.%m.%Y") | eval datefield=strftime(epochtime,"%d.%m.%Y") | chart list(VOL_DDC_OUT) by datefield,host useother=f | tail 15 | sort epochtime | fields - epochtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Oct 2016 17:08:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253800#M75975</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-10-13T17:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253801#M75976</link>
      <description>&lt;P&gt;Hello Rich,&lt;/P&gt;

&lt;P&gt;thanks for your fast answer! It is a very nice community.&lt;/P&gt;

&lt;P&gt;I got the same result &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I also tried to sort between the two eval commands.&lt;/P&gt;

&lt;P&gt;I still get the wrong sorting.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2016 05:40:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253801#M75976</guid>
      <dc:creator>Paul1896</dc:creator>
      <dc:date>2016-10-14T05:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253802#M75977</link>
      <description>&lt;P&gt;Try to sort on the epoch time and then do the time conversions&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2016 05:44:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253802#M75977</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2016-10-14T05:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253803#M75978</link>
      <description>&lt;P&gt;Hello cmerriman,&lt;/P&gt;

&lt;P&gt;thanks for your answer and your help!&lt;/P&gt;

&lt;P&gt;I reformated the date to Month/Day/year but now I only get the 01.10.2016 back.&lt;/P&gt;

&lt;P&gt;Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval epochtime=strptime(DATUM,"%m.%d.%Y")  | eval datefield=strftime(epochtime,"%m.%d.%Y") | chart list(VOL_DDC_OUT) by datefield,host useother=f | tail 15 | sort datefield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;01.10.2016  0   0 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I also tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval epochtime=strptime(DATUM,"%m.%d.%Y")  | eval datefield=strftime(epochtime,"%m.%d.%Y") | chart list(VOL_DDC_OUT) by datefield,host useother=f | tail 15 | sort epochtime | fields - epochtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval epochtime=strptime(DATUM,"%m.%d.%Y") | sort epochtime | eval datefield=strftime(epochtime,"%m.%d.%Y") | chart list(VOL_DDC_OUT) by datefield,host useother=f | tail 15  | fields - epochtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I only get the one value back.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2016 05:45:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253803#M75978</guid>
      <dc:creator>Paul1896</dc:creator>
      <dc:date>2016-10-14T05:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253804#M75979</link>
      <description>&lt;P&gt;You mean this way?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval epochtime=strptime(DATUM,"%d.%m.%Y") | sort epochtime  | eval datefield=strftime(epochtime,"%d.%m.%Y") | chart list(VOL_DDC_OUT) by datefield,host useother=f | tail 15  | fields - epochtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the same result back.&lt;/P&gt;

&lt;P&gt;Perhaps the chart-command overwrite all sort-commands?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2016 05:48:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253804#M75979</guid>
      <dc:creator>Paul1896</dc:creator>
      <dc:date>2016-10-14T05:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253805#M75980</link>
      <description>&lt;P&gt;Please try the query on my answer&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2016 05:48:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253805#M75980</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2016-10-14T05:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253806#M75981</link>
      <description>&lt;P&gt;Hello inventsekar,&lt;/P&gt;

&lt;P&gt;thanks for your fast answer!&lt;/P&gt;

&lt;P&gt;Here is the result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;01.10.2016  0   0    
17.09.2016  0   0   0
18.09.2016  0   0   0
19.09.2016  576     183     0
20.09.2016  0   0   0
21.09.2016  194     0   0
22.09.2016  317126  193     0
23.09.2016  30376   1127    0
24.09.2016  0   0   0
25.09.2016  0   0   0
26.09.2016  1725    18965   0
27.09.2016  21292   390     0
28.09.2016  26605   0   2895
29.09.2016  3324    21580   0
30.09.2016  85292   1352    0 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Oct 2016 05:52:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253806#M75981</guid>
      <dc:creator>Paul1896</dc:creator>
      <dc:date>2016-10-14T05:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253807#M75982</link>
      <description>&lt;P&gt;I also tried this one&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval datefield=strftime(strptime(DATUM,"%d.%m.%Y") ,"%Y.%m.%d") | chart list(VOL_RO) by datefield,host useother=f | tail 15 | sort +datefield

2016.09.17  0   4189590     52690
2016.09.18  0   4234501     52681
2016.09.19  1668    4262328     52668
2016.09.20  0   4286605     50382
2016.09.21  1349    4222331     50392
2016.09.22  6790    4218210     50392
2016.09.23  380     5412165     50392
2016.09.24  0   5200690     993555
2016.09.25  0   5094012     938512
2016.09.26  1128    4230430     50854
2016.09.27  0   5987518     50378
2016.09.28  1253    4259481     50392
2016.09.29  597     4547325     50392
2016.09.30  0   4624354     50392
2016.10.01  0   0    
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;At the moment this is the best solution, but it isn't the optimal result for me. If anyone have further ideas, it would be very nice!&lt;/P&gt;

&lt;P&gt;Thanks a lot for your great help!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2016 06:25:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253807#M75982</guid>
      <dc:creator>Paul1896</dc:creator>
      <dc:date>2016-10-14T06:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253808#M75983</link>
      <description>&lt;P&gt;check what happens with this one &lt;/P&gt;

&lt;P&gt;tail 15 | sort DATUM | chart list(VOL_DDC_OUT) by DATUM,host useother=f &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:25:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253808#M75983</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2020-09-29T11:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253809#M75984</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Given what you have so far I think you need to include epochtime in your chart command, so it becomes &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; eval epochtime=strptime(DATUM,"%d.%m.%Y") | eval datefield=strftime(epochtime,"%d.%m.%Y") | chart list(VOL_DDC_OUT) by epochtime, datefield,host useother=f | tail 15 | sort epochtime | fields - epochtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not sure why you're initially evaluating datefield as that is just the same value as DATUM isn't it? &lt;/P&gt;

&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2016 10:17:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253809#M75984</guid>
      <dc:creator>davebrooking</dc:creator>
      <dc:date>2016-10-14T10:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253810#M75985</link>
      <description>&lt;P&gt;could you do &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|convert mktime(DATNUM) as epochtime timeformat="%d.%m.%Y"| chart list(VOL_DDC_OUT) by epochtime,host useother=f | tail 15 | sort epochtime|convert ctime(epochtime) as datefield timeformat="%m/%d/%Y"|fields - epochtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Oct 2016 12:03:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253810#M75985</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2016-10-14T12:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: sort  show wrong result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253811#M75986</link>
      <description>&lt;P&gt;Try this untested query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval epochtime=strptime(DATUM,"%d.%m.%Y") | chart list(VOL_DDC_OUT) by epochtime,host useother=f | tail 15 | fieldformat epochtime=strftime(epochtime,"%d.%m.%Y")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Oct 2016 12:16:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-show-wrong-result/m-p/253811#M75986</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-10-17T12:16:46Z</dc:date>
    </item>
  </channel>
</rss>

