<?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: Sorting timechart series in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77537#M19596</link>
    <description>&lt;P&gt;The way we found to do this was with a subsearch and &lt;CODE&gt;return $field&lt;/CODE&gt;.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;get your sorting criteria (we ran &lt;CODE&gt;stats&lt;/CODE&gt; on a subset of the source data)&lt;/LI&gt;
&lt;LI&gt;sort the results&lt;/LI&gt;
&lt;LI&gt;use &lt;CODE&gt;fields&lt;/CODE&gt; to pull only the field used for your series&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;mvcombine&lt;/CODE&gt; to turn all the records into a single one&lt;/LI&gt;
&lt;LI&gt;then &lt;CODE&gt;eval&lt;/CODE&gt; with &lt;CODE&gt;mvjoin&lt;/CODE&gt; to make it into a comma or space-delimited string&lt;/LI&gt;
&lt;LI&gt;output with &lt;CODE&gt;return $&amp;lt;your list field&amp;gt;&lt;/CODE&gt; (the $ returns only the field's value)&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Probably a more efficient way out there, but this seems to work.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Nov 2012 23:22:14 GMT</pubDate>
    <dc:creator>jpreve</dc:creator>
    <dc:date>2012-11-06T23:22:14Z</dc:date>
    <item>
      <title>Sorting timechart series</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77532#M19591</link>
      <description>&lt;P&gt;We have a timechart that plots the number of entries of a specific type per day.  The types are numerical (2, 3, 4...10, 11 at the moment).&lt;/P&gt;

&lt;P&gt;Right now, doing a "timechart count by type" produces the type of chart we want, except that the first two series are 10 and 11 (so it is being ordered 10, 11, 2, 3, 4, 5, etc...)&lt;/P&gt;

&lt;P&gt;How do I reorder the search so that the series emerge in numerical order instead of lexicographical?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2010 02:20:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77532#M19591</guid>
      <dc:creator>simumichaelm</dc:creator>
      <dc:date>2010-10-26T02:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting timechart series</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77533#M19592</link>
      <description>&lt;P&gt;Have you tried this route?: &lt;CODE&gt;timechart count by type | sort num(type)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;(From: &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Sort" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/SearchReference/Sort&lt;/A&gt; )&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2010 05:26:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77533#M19592</guid>
      <dc:creator>David</dc:creator>
      <dc:date>2010-10-26T05:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting timechart series</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77534#M19593</link>
      <description>&lt;P&gt;1) If the numbers really are quite small it's probably best to just use the fields command to reorder them. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | fields _time 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2) or you could look into the &lt;CODE&gt;transpose&lt;/CODE&gt; command.  You could in theory transpose, sort and then transepose again.  However transpose has some strange characteristics and you'd have to use a lot of &lt;CODE&gt;eval&lt;/CODE&gt; contortions to end up with what you want.... &lt;/P&gt;

&lt;P&gt;3) if the numbers are NOT small, you dont want to have a fields command that lists every integer,  and you dont mind bucketing the split-by field a little, you can use this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | timechart count by date_second bins=10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Not many people know this, but if you put a bins argument after a split-by term, it actually buckets the split-by term....    So you end up with column values like "10-20",  "20-30", "30-40", "40-50" etc...   This may not be what you're looking for, but it has the nice side effect of sorting the buckets numerically. &lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2011 12:28:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77534#M19593</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-01-18T12:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting timechart series</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77535#M19594</link>
      <description>&lt;P&gt;Or prefix type with zero. &lt;/P&gt;

&lt;P&gt;... | eval type=if(type&amp;lt;10,"0"+type,type) | timechart ...&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2011 00:55:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77535#M19594</guid>
      <dc:creator>vbumgarner</dc:creator>
      <dc:date>2011-04-21T00:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting timechart series</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77536#M19595</link>
      <description>&lt;P&gt;the sort command will sort the rows by a field called 'type', but in a split-by clause like this the type values are columns.  So this question is really about sorting columns not rows.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2011 07:33:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77536#M19595</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-04-21T07:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting timechart series</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77537#M19596</link>
      <description>&lt;P&gt;The way we found to do this was with a subsearch and &lt;CODE&gt;return $field&lt;/CODE&gt;.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;get your sorting criteria (we ran &lt;CODE&gt;stats&lt;/CODE&gt; on a subset of the source data)&lt;/LI&gt;
&lt;LI&gt;sort the results&lt;/LI&gt;
&lt;LI&gt;use &lt;CODE&gt;fields&lt;/CODE&gt; to pull only the field used for your series&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;mvcombine&lt;/CODE&gt; to turn all the records into a single one&lt;/LI&gt;
&lt;LI&gt;then &lt;CODE&gt;eval&lt;/CODE&gt; with &lt;CODE&gt;mvjoin&lt;/CODE&gt; to make it into a comma or space-delimited string&lt;/LI&gt;
&lt;LI&gt;output with &lt;CODE&gt;return $&amp;lt;your list field&amp;gt;&lt;/CODE&gt; (the $ returns only the field's value)&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Probably a more efficient way out there, but this seems to work.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2012 23:22:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-timechart-series/m-p/77537#M19596</guid>
      <dc:creator>jpreve</dc:creator>
      <dc:date>2012-11-06T23:22:14Z</dc:date>
    </item>
  </channel>
</rss>

