<?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 do I get an Xyseries to display dates in descending order? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437691#M124613</link>
    <description>&lt;P&gt;@woodcock &lt;BR /&gt;
Ahhh! Your query gives me what I am looking for while its parsing, but when the search finishes it snaps to this instead and I am not sure why:( &lt;/P&gt;

&lt;P&gt;This removes all other date columns (the past 5 days) &amp;amp; displays only one day(31st which is outside of my 5 day range). &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;It now only looks like this&lt;/STRONG&gt;&lt;BR /&gt;
Department.....................1/31 &lt;BR /&gt;
dept1.............................. value&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jan 2019 21:26:23 GMT</pubDate>
    <dc:creator>ryhluc01</dc:creator>
    <dc:date>2019-01-30T21:26:23Z</dc:date>
    <item>
      <title>How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437685#M124607</link>
      <description>&lt;P&gt;sample query: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo "string of data"="age needed"age earliest=-5d
| stats dedup_splitvals=t , values(_time) AS _time  by dept, "age_needed"
| sort department 
| fields - _span  
| eval conv_age=strptime(Date,"%Y-%m-%dT%H:%M:%S.%Q")
| eval age=((now()-conv_age)/84000)
| eval day=strftime(_time,"%Y-%m-%d")
| stats avg(age) as super_Age by dept, day 
| eval super_Age=round(super_Age,2)
| xyseries Vertical day super_Age
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is a more detailed explanation of what I am looking for: &lt;BR /&gt;
Okay, so the column headers are the dates in my xyseries. I have a filter in my base search that limits the search to being within the past 5 days. &lt;/P&gt;

&lt;P&gt;Xyseries is displaying the 5 days as the earliest day first (on the left), and the current day being the last result to the right. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Dont Want&lt;/STRONG&gt;&lt;BR /&gt;
Dept.......... 1/26........1/27........1/28.........1/29...........1/30 &lt;STRONG&gt;(with the most recent being last)&lt;/STRONG&gt;&lt;BR /&gt;
dept1.....  value....... value .....value.......value...........value&lt;BR /&gt;
dept2.....  value....... value .....value.......value...........value&lt;/P&gt;

&lt;P&gt;I need for the order that the dates are being displayed to show me the most recent day first (i.e the current day) &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;This is what I want&lt;/STRONG&gt;&lt;BR /&gt;
Dept.......... 1/30........1/29........1/28.........1/27...........1/26 &lt;STRONG&gt;(with the oldest result being last)&lt;/STRONG&gt;&lt;BR /&gt;
dept1.....  value....... value .....value.......value...........value&lt;BR /&gt;
dept2.....  value....... value .....value.......value...........value&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 19:19:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437685#M124607</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-30T19:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437686#M124608</link>
      <description>&lt;P&gt;Hi @ryhluc01 &lt;/P&gt;

&lt;P&gt;Is it as simple as doing this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sample query: 
index=foo "string of data"="age needed"age earliest=-5d
| stats dedup_splitvals=t , values(_time) AS _time by dept, "age_needed"
| sort department 
| fields - _span 
| eval conv_age=strptime(Date,"%Y-%m-%dT%H:%M:%S.%Q")
| eval age=((now()-conv_age)/84000)
| eval _time = _time + 84000
| eval day=strftime(_time,"%Y-%m-%d")
| stats avg(age) as super_Age by dept, day 
| eval super_Age=round(super_Age,2)
| xyseries Vertical day super_Age
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Apologies if I have misunderstood the problem.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 19:22:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437686#M124608</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2019-01-30T19:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437687#M124609</link>
      <description>&lt;P&gt;Hey thanks for the speedy response! And no need to apologize. I appreciate your help.&lt;/P&gt;

&lt;P&gt;Ok so the addition of your time eval gives me tomorrows date and removes all other dates. &lt;BR /&gt;
essentially it ends up looking like this: &lt;/P&gt;

&lt;P&gt;department............1/31&lt;BR /&gt;
dept8......................value&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 19:36:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437687#M124609</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-30T19:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437688#M124610</link>
      <description>&lt;P&gt;Isn't the date already in descending . Sorry can you be more precise on the question?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 19:56:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437688#M124610</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-01-30T19:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437689#M124611</link>
      <description>&lt;P&gt;Sure! &lt;/P&gt;

&lt;P&gt;Okay so the column headers are the dates in my xyseries. I have a filter in my base search that limits the search to being within the past 5 day's. &lt;BR /&gt;
Xyseries is displaying the 5 day's as the earliest day first(on the left) and the current day being the last result to the right. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Dont Want&lt;/STRONG&gt;&lt;BR /&gt;
Dept.......... 1/26........1/27........1/28.........1/29...........1/30 &lt;STRONG&gt;(with the most recent being last)&lt;/STRONG&gt;&lt;BR /&gt;
dept1.....  value....... value .....value.......value...........value&lt;BR /&gt;
dept2.....  value....... value .....value.......value...........value&lt;/P&gt;

&lt;P&gt;I need for the order that the dates are being displayed to show me the most recent day first (i.e the current day) &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;This is what I want&lt;/STRONG&gt;&lt;BR /&gt;
Dept.......... 1/30........1/29........1/28.........1/27...........1/26 &lt;STRONG&gt;(with the oldest result being last)&lt;/STRONG&gt;&lt;BR /&gt;
dept1.....  value....... value .....value.......value...........value&lt;BR /&gt;
dept2.....  value....... value .....value.......value...........value&lt;/P&gt;

&lt;P&gt;Is this more helpful? &lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 20:11:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437689#M124611</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-30T20:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437690#M124612</link>
      <description>&lt;P&gt;Like this (by prepending each date with an ascending number of initial and INVISIBLE spaces):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo "string of data"="age needed"age earliest=-5d
| stats dedup_splitvals=t , values(_time) AS _time by dept, "age_needed"
| sort department 
| fields - _span 
| eval conv_age=strptime(Date,"%Y-%m-%dT%H:%M:%S.%Q")
| eval age=((now()-conv_age)/84000)
| eval _time = _time + 84000
| eval day=strftime(_time,"%Y-%m-%d")
| stats avg(age) as super_Age by dept, day 
| eval super_Age=round(super_Age,2)

| sort 0 day
| streamstats dc(day) AS spaces_count
| eval spaces_count = spaces_count - 1
| eval initialLength = len(day) 
| eval day = "                                                  " . day
| eval paddedLength = len(day)
| eval day = substr(day, paddedLength - initialLength - spaces_count + 1)

| xyseries dept day super_Age
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Jan 2019 20:42:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437690#M124612</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-01-30T20:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437691#M124613</link>
      <description>&lt;P&gt;@woodcock &lt;BR /&gt;
Ahhh! Your query gives me what I am looking for while its parsing, but when the search finishes it snaps to this instead and I am not sure why:( &lt;/P&gt;

&lt;P&gt;This removes all other date columns (the past 5 days) &amp;amp; displays only one day(31st which is outside of my 5 day range). &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;It now only looks like this&lt;/STRONG&gt;&lt;BR /&gt;
Department.....................1/31 &lt;BR /&gt;
dept1.............................. value&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 21:26:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437691#M124613</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-30T21:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437692#M124614</link>
      <description>&lt;P&gt;Woo hoo!!! It works when I remove this: &lt;/P&gt;

&lt;P&gt;| eval _time = _time + 84000&lt;/P&gt;

&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 21:50:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437692#M124614</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-30T21:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437693#M124615</link>
      <description>&lt;P&gt;@woodcock &lt;BR /&gt;
Hey is there a cleaner way to display this part? &lt;/P&gt;

&lt;P&gt;| eval day = "                                                  " . day&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 22:20:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437693#M124615</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-30T22:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437694#M124616</link>
      <description>&lt;P&gt;Check out the &lt;CODE&gt;printf&lt;/CODE&gt; function in splunk and also this Q&amp;amp;A for other potential options:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/46642/is-there-a-cleaner-way-to-zeropad-numeric-values-ie-add-leading-zeros.html"&gt;https://answers.splunk.com/answers/46642/is-there-a-cleaner-way-to-zeropad-numeric-values-ie-add-leading-zeros.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 22:24:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437694#M124616</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-01-30T22:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437695#M124617</link>
      <description>&lt;P&gt;Thanks ^_^&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 14:56:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437695#M124617</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-31T14:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an Xyseries to display dates in descending order?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437696#M124618</link>
      <description>&lt;P&gt;I've spent a lot of time on "ordering columns" recently and its uncovered a subtle difference between the xyseries command and an equivalent approach using the chart command.  So I think you'll find this does something close to what you're looking for ...&lt;BR /&gt;
index=_internal earliest=-5d@d latest=@d &lt;BR /&gt;
| bin _time span=1d&lt;BR /&gt;
| stats count by _time sourcetype&lt;BR /&gt;
| eval day=strftime(_time,"%m/%d") &lt;BR /&gt;
| sort - day &lt;BR /&gt;
| streamstats current=t window=0 global=t dc(day) AS dayNo &lt;BR /&gt;
| eval day=dayNo.":".day &lt;BR /&gt;
| chart first(count) over sourcetype by day &lt;BR /&gt;
| foreach &lt;EM&gt;:&lt;/EM&gt; &lt;BR /&gt;
    [ rename "&amp;lt;&lt;FIELD&gt;&amp;gt;" AS "&amp;lt;&lt;MATCHSEG2&gt;&amp;gt;" ]&lt;BR /&gt;
Play around with the +/- in the sort command (line 4) to get the column order you're looking for.  What I found strange is if you rewrite this using the xyseries command in place of the chart command (which is how I began), i.e. like this...&lt;BR /&gt;
index=_internal earliest=-5d@d latest=@d &lt;BR /&gt;
| bin _time span=1d &lt;BR /&gt;
| stats count by _time sourcetype &lt;BR /&gt;
| eval day=strftime(_time,"%m/%d") &lt;BR /&gt;
| sort + day &lt;BR /&gt;
| streamstats current=t window=0 global=t dc(day) AS dayNo &lt;BR /&gt;
| eval day=dayNo.":".day &lt;BR /&gt;
| xyseries sourcetype day count &lt;BR /&gt;
| foreach &lt;EM&gt;:&lt;/EM&gt; &lt;BR /&gt;
    [ rename "&amp;lt;&lt;FIELD&gt;&amp;gt;" AS "&amp;lt;&lt;MATCHSEG2&gt;&amp;gt;" ]&lt;BR /&gt;
...the rename command after the xyseries reorders the columns alphabetically.  Messing things up.&lt;BR /&gt;
By the way, either example above can be turbo-charged with tstats i.e.&lt;BR /&gt;
| tstats count where index=_internal earliest=-5d@d latest=@d by _time span=1h sourcetype&lt;BR /&gt;
| eval day=strftime(_time,"%m/%d") &lt;BR /&gt;
| sort + day &lt;BR /&gt;
| streamstats current=t window=0 global=t dc(day) AS dayNo &lt;BR /&gt;
| eval day=dayNo.":".day &lt;BR /&gt;
| chart first(count) over sourcetype by day &lt;BR /&gt;
| foreach &lt;EM&gt;:&lt;/EM&gt; &lt;BR /&gt;
    [ rename "&amp;lt;&lt;FIELD&gt;&amp;gt;" AS "&amp;lt;&lt;MATCHSEG2&gt;&amp;gt;" ]&lt;/MATCHSEG2&gt;&lt;/FIELD&gt;&lt;/MATCHSEG2&gt;&lt;/FIELD&gt;&lt;/MATCHSEG2&gt;&lt;/FIELD&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:58:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-an-Xyseries-to-display-dates-in-descending-order/m-p/437696#M124618</guid>
      <dc:creator>tread_splunk</dc:creator>
      <dc:date>2020-09-29T23:58:26Z</dc:date>
    </item>
  </channel>
</rss>

