<?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: Sorting X axis by month in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17826#M2512</link>
    <description>&lt;P&gt;Jason,&lt;/P&gt;

&lt;P&gt;Here's a cleaner eval that does the same:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Day=strftime(_time, "%u. %A") | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps makes it more readable &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 31 May 2012 23:44:03 GMT</pubDate>
    <dc:creator>assaphmehr</dc:creator>
    <dc:date>2012-05-31T23:44:03Z</dc:date>
    <item>
      <title>Sorting X axis by month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17822#M2508</link>
      <description>&lt;P&gt;I have the following search which displays amounts of records by month (X-axis).  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="billing" suspededrecords | eval monthnum = if(month="JAN",1,if(month="FEB",2,if(month="MAR",3,if(month="APR",4,if(month="MAY",5,if(month="JUN",6,if(month="JUL",7,if(month="AUG",8,if(month="SEP",9,if(month="OCT",10,if(month="NOV",11,if(month="DEC",0,0)))))))))))) |sort num(monthnum) | chart max(monthsuspense) as "Suspense" by month
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However the X-axis is always sorted month name alaphabetically which is confusing.  I put in the the above eval and sort statements to try and create fields that would allow the months to be displayed in the correct order, but it doesn't work. I'm starting to think that I starting to complicate the issue and wondered if there is an easy way to achieve a correct listing of months. &lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2010 17:36:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17822#M2508</guid>
      <dc:creator>mcwomble</dc:creator>
      <dc:date>2010-07-21T17:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting X axis by month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17823#M2509</link>
      <description>&lt;P&gt;I'd suggest you to use timechart, as you are plotting against time, and its bucketing options, to compute the max() over the entire month:&lt;/P&gt;

&lt;P&gt;timechart span="1mon" max(monthsuspense) as Suspense&lt;/P&gt;

&lt;P&gt;After your comment, I'm editing the answer...&lt;/P&gt;

&lt;P&gt;I've noticed that you issued the chart command using "month" and not "monthnum" as X-axis. Was this intentional? &lt;/P&gt;

&lt;P&gt;If noy, you might then want to:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;replace the monthnumber generation with something more compact;&lt;/LI&gt;
&lt;LI&gt;use the chart "over monthnum"&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;So that would end up as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="billing" suspededrecords | eval monthnum=strftime(strptime("2010/" + month + "/01", "%Y/%b/%d"),"%m") | chart max(monthsuspense) over monthnum span=1mon 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jul 2010 20:31:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17823#M2509</guid>
      <dc:creator>Paolo_Prigione</dc:creator>
      <dc:date>2010-07-21T20:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting X axis by month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17824#M2510</link>
      <description>&lt;P&gt;Unfortunately it doesn't seem to be as simple as creating a time chart.  The data that generates this graph comes in once a day from a dbquery which has the amounts defined by month and is effectively a snapshot at one moment in time. If reprocessing takes place the historical amount per month can change.  So really the month on the x-axis is just a field value rather than a distinct time event.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2010 02:46:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17824#M2510</guid>
      <dc:creator>mcwomble</dc:creator>
      <dc:date>2010-07-22T02:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting X axis by month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17825#M2511</link>
      <description>&lt;P&gt;I wrestled with this for a bit when trying to aggregate a particular day of the week's values over a month, and display the "average week" for the month. I could count by date_wday, but it the x axis would always be sorted lexigraphically. Very confusing.&lt;/P&gt;

&lt;P&gt;Here's my solution: use the eval to make a field with both a number for ordering as well as the name for easy viewing: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search ..... | eval Day = if(date_wday="sunday","1. Sunday",if(date_wday="monday","2. Monday",if(date_wday="tuesday","3. Tuesday",if(date_wday="wednesday","4. Wednesday",if(date_wday="thursday","5. Thursday",if(date_wday="friday","6. Friday",if(date_wday="saturday","7. Saturday",0)))))))| chart count over Day
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Aug 2010 23:47:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17825#M2511</guid>
      <dc:creator>Jason</dc:creator>
      <dc:date>2010-08-04T23:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting X axis by month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17826#M2512</link>
      <description>&lt;P&gt;Jason,&lt;/P&gt;

&lt;P&gt;Here's a cleaner eval that does the same:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Day=strftime(_time, "%u. %A") | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps makes it more readable &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2012 23:44:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-X-axis-by-month/m-p/17826#M2512</guid>
      <dc:creator>assaphmehr</dc:creator>
      <dc:date>2012-05-31T23:44:03Z</dc:date>
    </item>
  </channel>
</rss>

