<?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 Sort result of bin to draw distribution histogram in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sort-result-of-bin-to-draw-distribution-histogram/m-p/528329#M149173</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I'm trying to draw a distribution histogram of the duration to complete a specific action. The search is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index1 STATUS=Executed
| eval EXECUTED_DATE_e = strptime(EXECUTED_DATE, "%Y-%m-%d %H:%M:%S.%1N") 
| eval START_DATE_e = strptime(START_DATE, "%Y-%m-%d %H:%M:%S.%1N") 
| eval TTR = EXECUTED_DATE_e - START_DATE_e 
| bin bins=100 TTR
| stats count by TTR&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This produces the correct bins and counts, but the order is alphanumeric, which places 1000000-2000000 directly after 100000-200000, instead of 200000-300000. If I plot this result the bins are in the wrong location, and I cannot clearly interpret the distribution histogram.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="151px"&gt;-100000-0&lt;/TD&gt;&lt;TD width="69px"&gt;27531&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;0-100000&lt;/TD&gt;&lt;TD width="69px"&gt;151267&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;100000-200000&lt;/TD&gt;&lt;TD width="69px"&gt;14649&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1000000-1100000&lt;/TD&gt;&lt;TD width="69px"&gt;361&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1100000-1200000&lt;/TD&gt;&lt;TD width="69px"&gt;371&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1200000-1300000&lt;/TD&gt;&lt;TD width="69px"&gt;197&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1300000-1400000&lt;/TD&gt;&lt;TD width="69px"&gt;119&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1400000-1500000&lt;/TD&gt;&lt;TD width="69px"&gt;70&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1500000-1600000&lt;/TD&gt;&lt;TD width="69px"&gt;64&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1600000-1700000&lt;/TD&gt;&lt;TD width="69px"&gt;111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1700000-1800000&lt;/TD&gt;&lt;TD width="69px"&gt;76&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1800000-1900000&lt;/TD&gt;&lt;TD width="69px"&gt;69&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1900000-2000000&lt;/TD&gt;&lt;TD width="69px"&gt;27&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;200000-300000&lt;/TD&gt;&lt;TD width="69px"&gt;8390&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;2000000-2100000&lt;/TD&gt;&lt;TD width="69px"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;2100000-2200000&lt;/TD&gt;&lt;TD width="69px"&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;2200000-2300000&lt;/TD&gt;&lt;TD width="69px"&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;2300000-2400000&lt;/TD&gt;&lt;TD width="69px"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;2400000-2500000&lt;/TD&gt;&lt;TD width="69px"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Fri, 06 Nov 2020 13:33:35 GMT</pubDate>
    <dc:creator>BernardEAI</dc:creator>
    <dc:date>2020-11-06T13:33:35Z</dc:date>
    <item>
      <title>Sort result of bin to draw distribution histogram</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-result-of-bin-to-draw-distribution-histogram/m-p/528329#M149173</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I'm trying to draw a distribution histogram of the duration to complete a specific action. The search is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index1 STATUS=Executed
| eval EXECUTED_DATE_e = strptime(EXECUTED_DATE, "%Y-%m-%d %H:%M:%S.%1N") 
| eval START_DATE_e = strptime(START_DATE, "%Y-%m-%d %H:%M:%S.%1N") 
| eval TTR = EXECUTED_DATE_e - START_DATE_e 
| bin bins=100 TTR
| stats count by TTR&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This produces the correct bins and counts, but the order is alphanumeric, which places 1000000-2000000 directly after 100000-200000, instead of 200000-300000. If I plot this result the bins are in the wrong location, and I cannot clearly interpret the distribution histogram.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="151px"&gt;-100000-0&lt;/TD&gt;&lt;TD width="69px"&gt;27531&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;0-100000&lt;/TD&gt;&lt;TD width="69px"&gt;151267&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;100000-200000&lt;/TD&gt;&lt;TD width="69px"&gt;14649&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1000000-1100000&lt;/TD&gt;&lt;TD width="69px"&gt;361&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1100000-1200000&lt;/TD&gt;&lt;TD width="69px"&gt;371&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1200000-1300000&lt;/TD&gt;&lt;TD width="69px"&gt;197&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1300000-1400000&lt;/TD&gt;&lt;TD width="69px"&gt;119&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1400000-1500000&lt;/TD&gt;&lt;TD width="69px"&gt;70&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1500000-1600000&lt;/TD&gt;&lt;TD width="69px"&gt;64&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1600000-1700000&lt;/TD&gt;&lt;TD width="69px"&gt;111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1700000-1800000&lt;/TD&gt;&lt;TD width="69px"&gt;76&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1800000-1900000&lt;/TD&gt;&lt;TD width="69px"&gt;69&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;1900000-2000000&lt;/TD&gt;&lt;TD width="69px"&gt;27&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;200000-300000&lt;/TD&gt;&lt;TD width="69px"&gt;8390&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;2000000-2100000&lt;/TD&gt;&lt;TD width="69px"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;2100000-2200000&lt;/TD&gt;&lt;TD width="69px"&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;2200000-2300000&lt;/TD&gt;&lt;TD width="69px"&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;2300000-2400000&lt;/TD&gt;&lt;TD width="69px"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="151px"&gt;2400000-2500000&lt;/TD&gt;&lt;TD width="69px"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 06 Nov 2020 13:33:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-result-of-bin-to-draw-distribution-histogram/m-p/528329#M149173</guid>
      <dc:creator>BernardEAI</dc:creator>
      <dc:date>2020-11-06T13:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sort result of bin to draw distribution histogram</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-result-of-bin-to-draw-distribution-histogram/m-p/528331#M149175</link>
      <description>&lt;P&gt;The bin labels are strings rather than integers so they sort lexicographically.&amp;nbsp; Try this alternative&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... | stats count, first(START_DATE_e) as start by TTR
| sort + start
| fields - start&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 06 Nov 2020 13:50:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-result-of-bin-to-draw-distribution-histogram/m-p/528331#M149175</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-11-06T13:50:42Z</dc:date>
    </item>
    <item>
      <title>@Re: Sort result of bin to draw distribution histogram</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-result-of-bin-to-draw-distribution-histogram/m-p/528830#M149316</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this solution, but it didn't work. I eventually solved this by making a kvstore from a csv file, in which I defined the bins and their order. I could then get an order for each TTR bin, and then sort according to that order. For this to work you need to define the span and stick to it, otherwise the bin string changes, and then the lookup doesn't work anymore.&lt;/P&gt;&lt;P&gt;Therefore:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;bin span=1 TTR&lt;/LI-CODE&gt;&lt;P&gt;rather than:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;bin bins=400 TTR&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 13:40:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-result-of-bin-to-draw-distribution-histogram/m-p/528830#M149316</guid>
      <dc:creator>BernardEAI</dc:creator>
      <dc:date>2020-11-10T13:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: @Re: Sort result of bin to draw distribution histogram</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-result-of-bin-to-draw-distribution-histogram/m-p/649582#M224597</link>
      <description>&lt;P&gt;&lt;SPAN&gt;richgalloway's solution works, it was just missing one line of code. Try something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| bin indexlag as bin bins=100&lt;BR /&gt;| stats min(indexlag) as starting_value count BY bin&lt;BR /&gt;| sort starting_value&lt;BR /&gt;| fields - starting_value&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2023 07:11:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-result-of-bin-to-draw-distribution-histogram/m-p/649582#M224597</guid>
      <dc:creator>romedome</dc:creator>
      <dc:date>2023-07-07T07:11:30Z</dc:date>
    </item>
  </channel>
</rss>

