<?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: Changing the order of displayed single field values in a timechart column in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Changing-the-order-of-displayed-single-field-values-in-a/m-p/498330#M138845</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults count=2 
| streamstats count 
| eval _time=if((count == 2),relative_time('_time',"-7d@d"),relative_time('_time',"@d")) 
| makecontinuous span=1h 
| eval type="type".(random() % 4 +1) 
| table _time type
| timechart limit=0 count by type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, @sendijsd &lt;BR /&gt;
please try this query. Result is below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time,type1,type2,type3,type4
2019/11/30,4,7,8,5
2019/12/01,9,3,8,4
....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the current order.&lt;BR /&gt;
Use &lt;CODE&gt;fields&lt;/CODE&gt; or &lt;CODE&gt;table&lt;/CODE&gt; to change it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=2 
| streamstats count 
| eval _time=if((count == 2),relative_time('_time',"-7d@d"),relative_time('_time',"@d")) 
| makecontinuous span=1h 
| eval type="type".(random() % 4 +1) 
| table _time type
| timechart limit=0 count by type
| table _time type4,type3,type2,type1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I hope this can solve your problem.&lt;/P&gt;</description>
    <pubDate>Sat, 07 Dec 2019 11:50:42 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2019-12-07T11:50:42Z</dc:date>
    <item>
      <title>Changing the order of displayed single field values in a timechart column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Changing-the-order-of-displayed-single-field-values-in-a/m-p/498329#M138844</link>
      <description>&lt;P&gt;Hello, fellow Splunkers.&lt;/P&gt;

&lt;P&gt;I am currently trying to create a stacked timechart column using a simple search query: &lt;STRONG&gt;timechart count by type limit=0&lt;/STRONG&gt;&lt;BR /&gt;
Since Splunk uses lexicographical ordering by default, I ended up getting an undesired end result. &lt;/P&gt;

&lt;P&gt;In this particular situation, I have several &lt;STRONG&gt;types&lt;/STRONG&gt;(values of the single field) that I would like to display next to each other in the column chart and to do that I have tried assigning a numerical values by using &lt;STRONG&gt;eval/case&lt;/STRONG&gt; commands and then sorting the values like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;timechart count by type limit=0 | eval sort_field=case(type="type1",1, type="type2",2, type="type3",3, type="type4",4) | sort sort_field
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This approach had no effect whatsoever and no values were changed/re-ordered. As far as I can tell, not even the sort_field was created.I think there is a specific behavior when using this method with timecharts/charts, but I have not yet figured out a working solution. I managed to debug it a little bit further by trying to re-construct the search bit-by-bit and when I removed the timechart:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval sort_field=case(type="type1",1, type="type2",2, type="type3",3, type="type4",4) | sort sort_field
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I could see that the field(sort_field) only had 1 value(the first order value):&lt;BR /&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/8035i8C8E6498B320CFBF/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I do believe that there is a major syntax error on my part or something else entirely that I don't fundamentally understand yet. &lt;BR /&gt;
To sum it up, I am trying to create a column chart showing the count of events based on their type over a period of time. The problem is that the types(chart legend values) are being alphabetically ordered and I would like them to appear in a custom order on the chart.&lt;BR /&gt;
Perhaps there is someone with more charting experience willing to lend a helping hand? It would be most appreciated. &lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 23:43:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Changing-the-order-of-displayed-single-field-values-in-a/m-p/498329#M138844</guid>
      <dc:creator>sendijsd</dc:creator>
      <dc:date>2019-12-06T23:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the order of displayed single field values in a timechart column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Changing-the-order-of-displayed-single-field-values-in-a/m-p/498330#M138845</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults count=2 
| streamstats count 
| eval _time=if((count == 2),relative_time('_time',"-7d@d"),relative_time('_time',"@d")) 
| makecontinuous span=1h 
| eval type="type".(random() % 4 +1) 
| table _time type
| timechart limit=0 count by type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, @sendijsd &lt;BR /&gt;
please try this query. Result is below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time,type1,type2,type3,type4
2019/11/30,4,7,8,5
2019/12/01,9,3,8,4
....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the current order.&lt;BR /&gt;
Use &lt;CODE&gt;fields&lt;/CODE&gt; or &lt;CODE&gt;table&lt;/CODE&gt; to change it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=2 
| streamstats count 
| eval _time=if((count == 2),relative_time('_time',"-7d@d"),relative_time('_time',"@d")) 
| makecontinuous span=1h 
| eval type="type".(random() % 4 +1) 
| table _time type
| timechart limit=0 count by type
| table _time type4,type3,type2,type1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I hope this can solve your problem.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 11:50:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Changing-the-order-of-displayed-single-field-values-in-a/m-p/498330#M138845</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-07T11:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the order of displayed single field values in a timechart column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Changing-the-order-of-displayed-single-field-values-in-a/m-p/498331#M138846</link>
      <description>&lt;P&gt;Hey, @to4kawa&lt;/P&gt;

&lt;P&gt;This was exactly what I was looking for. I am accepting your answer, thank you very much!&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 13:36:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Changing-the-order-of-displayed-single-field-values-in-a/m-p/498331#M138846</guid>
      <dc:creator>sendijsd</dc:creator>
      <dc:date>2019-12-07T13:36:31Z</dc:date>
    </item>
  </channel>
</rss>

