<?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 do I sort a timechart legend by count in decreasing order, not alphabetically? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-sort-a-timechart-legend-by-count-in-decreasing-order/m-p/266245#M80054</link>
    <description>&lt;P&gt;If you have more than 9 in the legend add the following:&lt;BR /&gt;
| eval grp=if(len(grp)=1,"0".grp,grp)&lt;/P&gt;</description>
    <pubDate>Tue, 07 May 2019 14:42:30 GMT</pubDate>
    <dc:creator>gmorris_splunk</dc:creator>
    <dc:date>2019-05-07T14:42:30Z</dc:date>
    <item>
      <title>How do I sort a timechart legend by count in decreasing order, not alphabetically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-sort-a-timechart-legend-by-count-in-decreasing-order/m-p/266243#M80052</link>
      <description>&lt;P&gt;Let's say I've got a timechart of URLs I'm serving. Over an hour, let's say I served this:&lt;/P&gt;

&lt;P&gt;server.com/MYcats.html  - 22 hits&lt;BR /&gt;
server.com/MYdogs.html - 50 hits&lt;BR /&gt;
server.com/MYrabbits.html - 10 hits&lt;/P&gt;

&lt;P&gt;I would like the legend of my timechart to list those colored lines in order of number of hits:&lt;/P&gt;

&lt;P&gt;dogs&lt;BR /&gt;
cats&lt;BR /&gt;
rabbits&lt;/P&gt;

&lt;P&gt;But it sorts alphabetically. Here's [a shortened version of] my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex page_uri=*.html | rex field=page_uri "(?(?i)MY(\d)+)" | timechart count by animal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can someone help? I've looked through previous answers and haven't found the right thing.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2016 00:16:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-sort-a-timechart-legend-by-count-in-decreasing-order/m-p/266243#M80052</guid>
      <dc:creator>jofish</dc:creator>
      <dc:date>2016-05-21T00:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I sort a timechart legend by count in decreasing order, not alphabetically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-sort-a-timechart-legend-by-count-in-decreasing-order/m-p/266244#M80053</link>
      <description>&lt;P&gt;Unfortunately, short of hard coding the sequence of columns, splunk will default to sort alphabetically. However, its is possible to rename the cols so they appear in the right order, like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   index=myindex page_uri=*.html | rex field=page_uri "(?(?i)MY(\d)+)" | timechart count by animal | untable _time animal count | eventstats sum(count) as total by animal | sort - total | delta total as d | streamstats count(eval(d!=0)) as grp | eval animal=grp."-".animial | xyseries _time animal count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This does add a number prefix to the column name.&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2016 01:28:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-sort-a-timechart-legend-by-count-in-decreasing-order/m-p/266244#M80053</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-21T01:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I sort a timechart legend by count in decreasing order, not alphabetically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-sort-a-timechart-legend-by-count-in-decreasing-order/m-p/266245#M80054</link>
      <description>&lt;P&gt;If you have more than 9 in the legend add the following:&lt;BR /&gt;
| eval grp=if(len(grp)=1,"0".grp,grp)&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 14:42:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-sort-a-timechart-legend-by-count-in-decreasing-order/m-p/266245#M80054</guid>
      <dc:creator>gmorris_splunk</dc:creator>
      <dc:date>2019-05-07T14:42:30Z</dc:date>
    </item>
  </channel>
</rss>

