<?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: Why can't I get my search results to sort properly? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-get-my-search-results-to-sort-properly/m-p/200532#M58153</link>
    <description>&lt;P&gt;You don't have a field called &lt;CODE&gt;sortc&lt;/CODE&gt; after the chart command. You only have a field called &lt;CODE&gt;values(sortc)&lt;/CODE&gt; You should either change to &lt;CODE&gt;sort values(sortc)&lt;/CODE&gt; OR in your chart command alias the fieldname &lt;CODE&gt;values(sortc) as sortc&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Just on a different note, you should be able to combine your two eventstats in to one. &lt;CODE&gt;eventstats avg(seconds) as avgseconds count(URL_HEADER) as urlcount by URL_HEADER&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Sep 2016 16:03:36 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-09-19T16:03:36Z</dc:date>
    <item>
      <title>Why can't I get my search results to sort properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-get-my-search-results-to-sort-properly/m-p/200531#M58152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have this search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main | rex "(?i)\".*? /(?P&amp;lt;URL_HEADER&amp;gt;\w+/\w+)"| rex "(?i) UCT\-(?P&amp;lt;URL_MICRO_SECONDS&amp;gt;\d+)"|rex "(GET)(?&amp;lt;statusget&amp;gt;)"|rex "(POST)(?&amp;lt;statuspost&amp;gt;)"|eval seconds=URL_MICRO_SECONDS/1000000|eventstats avg(seconds) as avgseconds by URL_HEADER|eventstats count(URL_HEADER) as urlcount by URL_HEADER|eval sortc=avgseconds*urlcount|chart values(sortc) sparkline(avg(seconds)) as Trend avg(seconds) as "Average Seconds" max(seconds) as "Maximum Seconds" min(seconds) as "Minimum Seconds" last(seconds) as Current perc90(seconds) as "90th Percentile" count(URL_HEADER) as "URL Execution Count" sparkline(count(statusget)) as "Trend - GET" count(statusget) as "# of GETs" sparkline(count(statuspost)) as "Trend - POST" count(statuspost) as "# of POSTs" by URL_HEADER|sort sortc|rename URL_HEADER as "URL Header - Click for Details"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And for whatever reason I cannot get it to sort on the sortc value.  I get results that look like this.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1870i172CF0B00F5A608E/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2016 15:54:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-get-my-search-results-to-sort-properly/m-p/200531#M58152</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-09-19T15:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I get my search results to sort properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-get-my-search-results-to-sort-properly/m-p/200532#M58153</link>
      <description>&lt;P&gt;You don't have a field called &lt;CODE&gt;sortc&lt;/CODE&gt; after the chart command. You only have a field called &lt;CODE&gt;values(sortc)&lt;/CODE&gt; You should either change to &lt;CODE&gt;sort values(sortc)&lt;/CODE&gt; OR in your chart command alias the fieldname &lt;CODE&gt;values(sortc) as sortc&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Just on a different note, you should be able to combine your two eventstats in to one. &lt;CODE&gt;eventstats avg(seconds) as avgseconds count(URL_HEADER) as urlcount by URL_HEADER&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2016 16:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-get-my-search-results-to-sort-properly/m-p/200532#M58153</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-09-19T16:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I get my search results to sort properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-get-my-search-results-to-sort-properly/m-p/200533#M58154</link>
      <description>&lt;P&gt;Hi Sundareshr!&lt;/P&gt;

&lt;P&gt;Ahhhh I wasn't aware that by using values(sortc) it actually changes the field name from sortc to "values(sortc)"  interesting.&lt;/P&gt;

&lt;P&gt;Thanks for the update on the eventstats!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2016 18:27:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-get-my-search-results-to-sort-properly/m-p/200533#M58154</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-09-19T18:27:11Z</dc:date>
    </item>
  </channel>
</rss>

