<?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 to sort a chart based on a sum? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461184#M130079</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=corp_splunk_license_details day="12-11-2019" | eval Volume_gb = round(volume_gb,3)  
| chart sum(Volume_gb) as "Amount Indexed (GB)" by day, orig_index  | addtotals 
| sort Total 
| fields - Total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 12 Dec 2019 15:45:43 GMT</pubDate>
    <dc:creator>vnravikumar</dc:creator>
    <dc:date>2019-12-12T15:45:43Z</dc:date>
    <item>
      <title>How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461181#M130076</link>
      <description>&lt;P&gt;I dump Splunk daily indexing into a summary index for long term retention and quicker searching. But now I'm trying to chart the data and I'm stuck trying to get the summed data to sort properly. Not a huge deal but does make it more visually appealing.&lt;/P&gt;

&lt;P&gt;Here's my search:&lt;BR /&gt;
    index=corp_splunk_license_details day="12-11-2019" | eval Volume_gb = round(volume_gb,3)  | chart sum(Volume_gb) as "Amount Indexed (GB)" by day, orig_index&lt;/P&gt;

&lt;P&gt;And here are my results:&lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/276729-2019-12-12-09-18-56-search-splunk-7013.png" alt="unsorted result chart" /&gt;&lt;/P&gt;

&lt;P&gt;Here is an example of the raw events in the index as well:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;12/11/2019 00:00:00 -0500, search_name=corp_splunk_license_index_per_day, search_now=1576130400.000, info_min_time=1576040400.000, info_max_time=1576126800.000, info_search_time=1576131051.720, day="12-11-2019", orig_index=index1, volume_gb="0.21123013552278280000000"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would really like to have the chart sorted from largest to smallest.&lt;/P&gt;

&lt;P&gt;Thanks for the help as usual!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:19:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461181#M130076</guid>
      <dc:creator>jeck11</dc:creator>
      <dc:date>2020-09-30T03:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461182#M130077</link>
      <description>&lt;P&gt;Did you try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query...
| sort "Amount Indexed (GB)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Dec 2019 14:55:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461182#M130077</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2019-12-12T14:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461183#M130078</link>
      <description>&lt;P&gt;I've tried a few things but none have worked out so far. I did just try your solution as well and couldn't get it to sort either. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=corp_splunk_license_details day="12-11-2019" | eval Volume_gb = round(volume_gb,3)  | chart sum(Volume_gb) as "Amount Indexed (GB)" by day, orig_index  | sort "Amount Indexed (GB)"

and

index=corp_splunk_license_details day="12-11-2019" | eval Volume_gb = round(volume_gb,3)  | chart sum(Volume_gb) as "Amount Indexed (GB)" by day, orig_index  | sort "Volume_gb"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Dec 2019 15:13:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461183#M130078</guid>
      <dc:creator>jeck11</dc:creator>
      <dc:date>2019-12-12T15:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461184#M130079</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=corp_splunk_license_details day="12-11-2019" | eval Volume_gb = round(volume_gb,3)  
| chart sum(Volume_gb) as "Amount Indexed (GB)" by day, orig_index  | addtotals 
| sort Total 
| fields - Total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Dec 2019 15:45:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461184#M130079</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-12-12T15:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461185#M130080</link>
      <description>&lt;P&gt;Nope. That didn't appear to change anything.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 15:50:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461185#M130080</guid>
      <dc:creator>jeck11</dc:creator>
      <dc:date>2019-12-12T15:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461186#M130081</link>
      <description>&lt;P&gt;Do you need the &lt;STRONG&gt;by day&lt;/STRONG&gt; clause if you're already filtering by day in the search? Are you doing that for the different bar colors?&lt;BR /&gt;
If you remove it and use the sort command it should sort the bars. I think that second clause in your stats sum() is preventing the sorting. Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=corp_splunk_license_details day="12-11-2019" 
| eval Volume_gb = round(volume_gb,3)  
| chart sum(Volume_gb) as "Amount Indexed (GB)" by orig_index  
| sort  "Amount Indexed (GB)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Dec 2019 16:33:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461186#M130081</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2019-12-12T16:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461187#M130082</link>
      <description>&lt;P&gt;Perfect! TY. &lt;/P&gt;

&lt;P&gt;The color-coding is nice for quickly identifying which index is which but using your code sorted it. The only tweak I made was to reverse it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=corp_splunk_license_details day="12-11-2019" 
 | eval Volume_gb = round(volume_gb,3)  
 | chart sum(Volume_gb) as "Amount Indexed (GB)" by orig_index  
 | sort  - "Amount Indexed (GB)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Dec 2019 16:43:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461187#M130082</guid>
      <dc:creator>jeck11</dc:creator>
      <dc:date>2019-12-12T16:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461188#M130083</link>
      <description>&lt;P&gt;Great! Just realized that I responded under the wrong answer. Could you please mark my answer below as the right one?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 16:46:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461188#M130083</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2019-12-12T16:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461189#M130084</link>
      <description>&lt;P&gt;Do you need the &lt;STRONG&gt;by day&lt;/STRONG&gt; clause if you're already filtering by day in the search? Are you doing that for the different bar colors?&lt;BR /&gt;
If you remove it and use the sort command it should sort the bars. I think that second clause in your stats sum() is preventing the sorting. Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=corp_splunk_license_details day="12-11-2019" 
| eval Volume_gb = round(volume_gb,3)  
| chart sum(Volume_gb) as "Amount Indexed (GB)" by orig_index  
| sort  "Amount Indexed (GB)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Dec 2019 16:46:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461189#M130084</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2019-12-12T16:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461190#M130085</link>
      <description>&lt;P&gt;@jeck11  Great! Just realized that I responded under the wrong answer. Could you please mark this as the correct answer? Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 16:49:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461190#M130085</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2019-12-12T16:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461191#M130086</link>
      <description>&lt;P&gt;@jeck11 Hi. Could you please correct the right answer?&lt;BR /&gt;
Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 14:27:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461191#M130086</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2019-12-13T14:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461192#M130087</link>
      <description>&lt;P&gt;Hi @oscar84x  - I've been trying to change it. How can I unselect the other one and switch it to yours?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 14:45:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461192#M130087</guid>
      <dc:creator>jeck11</dc:creator>
      <dc:date>2019-12-13T14:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461193#M130088</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Unaccept my answer and accept his answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
@oscar84x - update/move your comments to answer&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 14:50:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461193#M130088</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-12-13T14:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461194#M130089</link>
      <description>&lt;P&gt;@jeck11 @vnravikumar haha Sorry for the confusion. It had already been sorted out by one of the admins and you actually just undid it. I'm just going to add it as a separate answer and if you can mark that one as correct that would be great. I won't pressure you.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 15:05:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461194#M130089</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2019-12-13T15:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461195#M130090</link>
      <description>&lt;P&gt;Do you need the &lt;STRONG&gt;by day&lt;/STRONG&gt; clause if you're already filtering by day in the search? Are you doing that for the different bar colors?&lt;BR /&gt;
If you remove it and use the sort command it should sort the bars. I think that second clause in your stats sum() is preventing the sorting. Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=corp_splunk_license_details day="12-11-2019" 
| eval Volume_gb = round(volume_gb,3)  
| chart sum(Volume_gb) as "Amount Indexed (GB)" by orig_index  
| sort  "Amount Indexed (GB)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Dec 2019 15:06:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461195#M130090</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2019-12-13T15:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461196#M130091</link>
      <description>&lt;P&gt;@jeck11 Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 15:40:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461196#M130091</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2019-12-13T15:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort a chart based on a sum?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461197#M130092</link>
      <description>&lt;P&gt;@oscar84x - no, thank you. Sorry for the confusion.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 15:51:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-a-chart-based-on-a-sum/m-p/461197#M130092</guid>
      <dc:creator>jeck11</dc:creator>
      <dc:date>2019-12-13T15:51:23Z</dc:date>
    </item>
  </channel>
</rss>

