<?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 Sorting the legend in a graph newest date to oldest from top to bottom in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sorting-the-legend-in-a-graph-newest-date-to-oldest-from-top-to/m-p/403439#M116741</link>
    <description>&lt;P&gt;This is my search. It is multiple timecharts timewraped per week &lt;/P&gt;

&lt;P&gt;SEARCH:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=... earliest=@w1 latest=+7d@w1| 
timechart span=5m 
max(KPI1) as Registrations | timewrap w series=exact |
appendcols [search 
index=... earliest=-7d@w1 latest=@w1| 
timechart span=5m 
max(KPI1) as Registrations | timewrap w series=exact 
] | appendcols [search 
index=... earliest=-14d@w1 latest=-7d@w1| 
timechart span=5m 
max(KPI1) as Registrations | timewrap w series=exact
] | appendcols [search 
index=... earliest=-21d@w1 latest=-14d@w1| 
timechart span=5m 
max(KPI1) as Registrations | timewrap w series=exact
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;GRAPH:&lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/250715-timewrap.png" alt="Graph with Legend Not ordered as I would like" /&gt;&lt;/P&gt;

&lt;P&gt;This is my graph that is generated. But the legend appears like this &lt;/P&gt;

&lt;P&gt;Registrations_week_of_May14&lt;BR /&gt;
Registrations_week_of_Apr23&lt;BR /&gt;
Registrations_week_of_Apr30&lt;BR /&gt;
Registrations_week_of_May07&lt;/P&gt;

&lt;P&gt;I want it to appear as this: (preferably with the newest date reading from top to bottom or alternatively with the oldest date reading from top to bottom.)&lt;BR /&gt;&lt;BR /&gt;
Registrations_week_of_May07&lt;BR /&gt;
Registrations_week_of_May14&lt;BR /&gt;
Registrations_week_of_Apr23&lt;BR /&gt;
Registrations_week_of_Apr30&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 19:34:36 GMT</pubDate>
    <dc:creator>HattrickNZ</dc:creator>
    <dc:date>2020-09-29T19:34:36Z</dc:date>
    <item>
      <title>Sorting the legend in a graph newest date to oldest from top to bottom</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-the-legend-in-a-graph-newest-date-to-oldest-from-top-to/m-p/403439#M116741</link>
      <description>&lt;P&gt;This is my search. It is multiple timecharts timewraped per week &lt;/P&gt;

&lt;P&gt;SEARCH:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=... earliest=@w1 latest=+7d@w1| 
timechart span=5m 
max(KPI1) as Registrations | timewrap w series=exact |
appendcols [search 
index=... earliest=-7d@w1 latest=@w1| 
timechart span=5m 
max(KPI1) as Registrations | timewrap w series=exact 
] | appendcols [search 
index=... earliest=-14d@w1 latest=-7d@w1| 
timechart span=5m 
max(KPI1) as Registrations | timewrap w series=exact
] | appendcols [search 
index=... earliest=-21d@w1 latest=-14d@w1| 
timechart span=5m 
max(KPI1) as Registrations | timewrap w series=exact
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;GRAPH:&lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/250715-timewrap.png" alt="Graph with Legend Not ordered as I would like" /&gt;&lt;/P&gt;

&lt;P&gt;This is my graph that is generated. But the legend appears like this &lt;/P&gt;

&lt;P&gt;Registrations_week_of_May14&lt;BR /&gt;
Registrations_week_of_Apr23&lt;BR /&gt;
Registrations_week_of_Apr30&lt;BR /&gt;
Registrations_week_of_May07&lt;/P&gt;

&lt;P&gt;I want it to appear as this: (preferably with the newest date reading from top to bottom or alternatively with the oldest date reading from top to bottom.)&lt;BR /&gt;&lt;BR /&gt;
Registrations_week_of_May07&lt;BR /&gt;
Registrations_week_of_May14&lt;BR /&gt;
Registrations_week_of_Apr23&lt;BR /&gt;
Registrations_week_of_Apr30&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:34:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-the-legend-in-a-graph-newest-date-to-oldest-from-top-to/m-p/403439#M116741</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2020-09-29T19:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the legend in a graph newest date to oldest from top to bottom</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-the-legend-in-a-graph-newest-date-to-oldest-from-top-to/m-p/403440#M116742</link>
      <description>&lt;P&gt;@HattrickNZ, the idea of Timewrap command is for you to write a single search for complete timerange and let the command create Time bucket for series comparison.&lt;/P&gt;

&lt;P&gt;For example the following run anywhere search. However, as you would have seen the resulting series will be sorted in chronological order. In your case you can optionally also use &lt;CODE&gt;time_format="Week of %Y-%m-%d"&lt;/CODE&gt; :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=-21d@w1 latest=+7d@w1 
| eval KPI1=random()
| timechart span=5m max(KPI1) as Registrations_w1 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since, you need the series to be reverse sorted and already have used the &lt;CODE&gt;appendcol&lt;/CODE&gt; command. All you need to do is rename the series to something meaningful format and adjust x-axis for same time-range, to let the series overlap. Refer to this Splunk blog: &lt;A href="https://www.splunk.com/blog/2012/02/19/compare-two-time-ranges-in-one-report.html"&gt;https://www.splunk.com/blog/2012/02/19/compare-two-time-ranges-in-one-report.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Following is run anywhere example to test:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=@w1 latest=+7d@w1 
| eval KPI1=random() 
| timechart span=5m max(KPI1) as Registrations_current_week
| appendcols 
    [ search 
        index=_internal earliest=-7d@w1 latest=@w1 
    | eval KPI1=random() 
    | timechart span=5m max(KPI1) as Registrations_last_07days
    |  eval _time=_time+60*60*24*7 ] 
| appendcols 
    [ search 
        index=_internal earliest=-14d@w1 latest=-7d@w1 
    | eval KPI1=random() 
    | timechart span=5m max(KPI1) as Registrations_last_14days
    | eval _time=_time+60*60*24*14 
        ] 
| appendcols 
    [ search 
        index=_internal earliest=-21d@w1 latest=-14d@w1 
    | eval KPI1=random() 
    | timechart span=5m max(KPI1) as Registrations_last_21days
    | eval _time=_time+60*60*24*21
        ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 May 2018 15:19:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-the-legend-in-a-graph-newest-date-to-oldest-from-top-to/m-p/403440#M116742</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-18T15:19:28Z</dc:date>
    </item>
  </channel>
</rss>

