<?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: unable to sort the month fields chronological instead of alphabetically in output in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/746978#M241737</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;&amp;nbsp; The issue is in my query I am fetching data for last 6 months. so If someone run the query till date it will give results from December till now and also there is 0 count for some months, so it will look blank. something like this if I hardcode the months&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mchoudhary_0-1748341387286.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39161i858E3AA73A05D2D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mchoudhary_0-1748341387286.png" alt="mchoudhary_0-1748341387286.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 27 May 2025 10:23:40 GMT</pubDate>
    <dc:creator>mchoudhary</dc:creator>
    <dc:date>2025-05-27T10:23:40Z</dc:date>
    <item>
      <title>unable to sort the month fields chronological instead of alphabetically in output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/746974#M241735</link>
      <description>&lt;P&gt;Hi Everyone!&lt;BR /&gt;&lt;BR /&gt;I wrote a search query to get the blocked count of emails for last 6months and below is my query-&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats summariesonly=false dc(Message_Log.msg.header.message-id) as Blocked from datamodel=pps_ondemand where (Message_Log.filter.routeDirection="inbound") AND (Message_Log.filter.disposition="discard" OR Message_Log.filter.disposition="reject" OR Message_Log.filter.quarantine.folder="Spam*") earliest=-6mon@mon latest=now by _time
| eval Source="Email"
| eval Month=strftime(_time, "%b")
| stats sum(Blocked) as Blocked by Source Month
| eventstats sum(Blocked) as Total by Source
| appendpipe [ stats values(Total) as Blocked by Source | eval Month="Total" ]
| xyseries Source Month Blocked
| fillnull value=0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and its output looks something like this -&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mchoudhary_0-1748340339620.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39160i0229D08687C44936/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mchoudhary_0-1748340339620.png" alt="mchoudhary_0-1748340339620.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The only issue is in the output the month field is not chronologically sorted instead it is alphabetical. I intend to sort it chronologically. I tried with the below query as well to achieve the desired output but no go-&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval MonthNum=strftime(_time, "%Y-%m"), MonthName=strftime(_time, "%b")
| stats sum(Blocked) as Blocked by Source MonthNum MonthName
| eventstats sum(Blocked) as Total by Source
| appendpipe [ stats values(Total) as Blocked by Source | eval MonthNum="9999-99", MonthName="Total" ]
| sort MonthNum
| eval Month=MonthName
| table Source Month Blocked&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone please help here!&lt;/P&gt;&lt;P&gt;Thanks In advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 10:13:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/746974#M241735</guid>
      <dc:creator>mchoudhary</dc:creator>
      <dc:date>2025-05-27T10:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: unable to sort the month fields chronological instead of alphabetically in output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/746975#M241736</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/276624"&gt;@mchoudhary&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The easiest way might be to add a table on the end, something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| table Source Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec *&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 10:16:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/746975#M241736</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-05-27T10:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: unable to sort the month fields chronological instead of alphabetically in output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/746978#M241737</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;&amp;nbsp; The issue is in my query I am fetching data for last 6 months. so If someone run the query till date it will give results from December till now and also there is 0 count for some months, so it will look blank. something like this if I hardcode the months&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mchoudhary_0-1748341387286.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39161i858E3AA73A05D2D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mchoudhary_0-1748341387286.png" alt="mchoudhary_0-1748341387286.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 10:23:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/746978#M241737</guid>
      <dc:creator>mchoudhary</dc:creator>
      <dc:date>2025-05-27T10:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: unable to sort the month fields chronological instead of alphabetically in output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747093#M241750</link>
      <description>&lt;P&gt;Instead of computing month before xyseries, it's better to carry _time into xyseries and use transpose to get your final layout. &amp;nbsp;Unlike xyseries, transpose preserves row order into column order.&lt;/P&gt;&lt;P&gt;But then, given that you only have one prescribed "source", I wonder if xyseries and streamstats are a waste. &amp;nbsp;How about&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats summariesonly=false dc(Message_Log.msg.header.message-id) as Blocked
  from datamodel=pps_ondemand
  where (Message_Log.filter.routeDirection="inbound")
    AND (Message_Log.filter.disposition="discard"
      OR Message_Log.filter.disposition="reject"
      OR Message_Log.filter.quarantine.folder="Spam*")
  earliest=-6mon@mon latest=now by _time span=1month@month
| eval Month=strftime(_time, "%b")
| transpose header_field=month column_name=Source
| eval Source = "Email"
| fillnull value=0
| addtotals&lt;/LI-CODE&gt;&lt;P&gt;Here, I removed the first stats sum because by using span=1mon@mon in tstats, that calculation is already done. &amp;nbsp;I also removed eventstats and streamstats because total on row is more easily performed with &lt;A href="https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/latest/search-commands/addtotals" target="_blank" rel="noopener"&gt;addtotals&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2025 07:18:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747093#M241750</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-05-28T07:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: unable to sort the month fields chronological instead of alphabetically in output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747097#M241753</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/276624"&gt;@mchoudhary&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You can try below,&lt;BR /&gt;&lt;BR /&gt;| tstats summariesonly=false dc(Message_Log.msg.header.message-id) as Blocked from datamodel=pps_ondemand&lt;BR /&gt;where (Message_Log.filter.routeDirection="inbound")&lt;BR /&gt;AND (Message_Log.filter.disposition="discard" OR Message_Log.filter.disposition="reject" OR Message_Log.filter.quarantine.folder="Spam*")&lt;BR /&gt;earliest=-6mon@mon latest=now by _time&lt;BR /&gt;| eval Source="Email"&lt;BR /&gt;| eval MonthNum=strftime(_time, "%Y-%m"), MonthName=strftime(_time, "%b")&lt;BR /&gt;| stats sum(Blocked) as Blocked by Source MonthNum MonthName&lt;BR /&gt;| eventstats sum(Blocked) as Total by Source&lt;BR /&gt;| appendpipe [ stats values(Total) as Blocked by Source | eval MonthNum="9999-99", MonthName="Total" ]&lt;BR /&gt;| sort MonthNum&lt;BR /&gt;| eval Month=MonthName&lt;BR /&gt;| table Source Month Blocked&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a kudos. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2025 07:45:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747097#M241753</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-05-28T07:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: unable to sort the month fields chronological instead of alphabetically in output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747113#M241757</link>
      <description>&lt;P&gt;Okay&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/276624"&gt;@mchoudhary&lt;/a&gt;&amp;nbsp;- this might look a little bizarre but stay with me....you could use the following table output, this uses a search to determine the months returned based on the earliest/latest set by the time picker and lists them out as per the screenshot below. Would this work for you?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| table Source [| makeresults count=12
  | streamstats count as month_offset
 | addinfo
  | eval start_epoch=info_min_time, end_epoch=info_max_time
  | eval start_month=strftime(start_epoch, "%Y-%m-01")
  | eval month_epoch = relative_time(strptime(start_month, "%Y-%m-%d"), "+" . (month_offset-1) . "mon")
  | where month_epoch &amp;lt;= end_epoch
  | eval month=strftime(month_epoch, "%b")
  | stats list(month) as search
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1748428246358.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39221i06C6536D62645C27/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1748428246358.png" alt="livehybrid_0-1748428246358.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|tstats count where index=main by _time span=1d
| eval MonthNum=strftime(_time, "%Y-%m"), MonthName=strftime(_time, "%b")
| eval Source="Email"
| eval Blocked=count
| stats sum(Blocked) as Blocked by Source MonthNum MonthName
| xyseries Source MonthName Blocked
| addinfo
| table Source [| makeresults count=60
  | streamstats count as month_offset
 | addinfo
  | eval start_epoch=info_min_time, end_epoch=info_max_time
  | eval start_month=strftime(start_epoch, "%Y-%m-01")
  | eval month_epoch = relative_time(strptime(start_month, "%Y-%m-%d"), "+" . (month_offset-1) . "mon")
  | where month_epoch &amp;lt;= end_epoch
  | eval month=strftime(month_epoch, "%b")
  | stats list(month) as search
]&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2025 10:31:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747113#M241757</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-05-28T10:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: unable to sort the month fields chronological instead of alphabetically in output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747143#M241768</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I tried the same query as you suggested, not sure why it is giving me data only for May month &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats summariesonly=false dc(Message_Log.msg.header.message-id) as Blocked from datamodel=pps_ondemand where (Message_Log.filter.routeDirection="inbound") AND (Message_Log.filter.disposition="discard" OR Message_Log.filter.disposition="reject" OR Message_Log.filter.quarantine.folder="Spam*") earliest=-6mon@mon latest=now by _time
| eval Source="Email"
| eval MonthNum=strftime(_time, "%Y-%m"), MonthName=strftime(_time, "%b")
| stats sum(Blocked) as Blocked by Source MonthNum MonthName
| xyseries Source MonthName Blocked
| addinfo
| table Source [| makeresults count=60
  | streamstats count as month_offset
 | addinfo
  | eval start_epoch=info_min_time, end_epoch=info_max_time
  | eval start_month=strftime(start_epoch, "%Y-%m-01")
  | eval month_epoch = relative_time(strptime(start_month, "%Y-%m-%d"), "+" . (month_offset-1) . "mon")
  | where month_epoch &amp;lt;= end_epoch
  | eval month=strftime(month_epoch, "%b")
  | stats list(month) as search
]&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mchoudhary_0-1748457815062.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39226iD761021181D2BA7C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mchoudhary_0-1748457815062.png" alt="mchoudhary_0-1748457815062.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2025 18:48:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747143#M241768</guid>
      <dc:creator>mchoudhary</dc:creator>
      <dc:date>2025-05-28T18:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: unable to sort the month fields chronological instead of alphabetically in output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747147#M241769</link>
      <description>&lt;P&gt;Ah! Okay, this is because you're using earliest/latest not the time-picker, we can fix that - try the below table section instead:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| table Source [| makeresults count=7
  | streamstats count as month_offset
  | eval start_epoch=relative_time(now(),"-6mon@mon"), end_epoch=now()
  | eval start_month=strftime(start_epoch, "%Y-%m-01")
  | eval month_epoch = relative_time(strptime(start_month, "%Y-%m-%d"), "+" . (month_offset-1) . "mon")
  | where month_epoch &amp;lt;= end_epoch
  | eval month=strftime(month_epoch, "%b")
  | stats list(month) as search
]&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2025 20:31:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747147#M241769</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-05-28T20:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: unable to sort the month fields chronological instead of alphabetically in output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747191#M241778</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;&amp;nbsp;It worked like magic! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thank you so much.&lt;/P&gt;&lt;P&gt;Also, if you could explain the logic behind it, I would be grateful &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 12:00:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747191#M241778</guid>
      <dc:creator>mchoudhary</dc:creator>
      <dc:date>2025-05-29T12:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: unable to sort the month fields chronological instead of alphabetically in output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747195#M241779</link>
      <description>&lt;P&gt;Absolutely&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/276624"&gt;@mchoudhary&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, what we are doing here is using a subsearch within the "table" command to generate the list of months you are interested in. Not many people realise but you can use a subsearch in a lot more places than as part of an original search, e.g. to derive a variable for timechart span, or in our case to list some fields for your table command.&lt;/P&gt;&lt;P&gt;Regarding the subsearch, this is what it is doing:&lt;/P&gt;&lt;P&gt;1. | makeresults count=7&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Generates 7 dummy events (rows) to work with in the pipeline. (6 months ago + current month)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;2. | streamstats count as month_offset&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;For each of the 7 rows, assigns a sequential number in month_offset (from 1 to 7).&lt;/LI&gt;&lt;LI&gt;This will be used to generate one value per month, going backwards in time.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;3. | eval start_epoch=relative_time(now(),"-6mon@mon"), end_epoch=now()&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;start_epoch calculates the epoch time at the start of the month, six months ago.&lt;UL&gt;&lt;LI&gt;-6mon@mon: Go back 6 months, then snap to the beginning of the month.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;end_epoch is the current epoch time.&lt;/LI&gt;&lt;LI&gt;This sets the time range: from the start of 6 months ago until now.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;4. | eval start_month=strftime(start_epoch, "%Y-%m-01")&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Formats start_epoch into a string representing the first day of the starting month (e.g., "2024-11-01").&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;5. | eval month_epoch = relative_time(strptime(start_month, "%Y-%m-%d"), "+" . (month_offset-1) . "mon")&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;For each row, this creates a timestamp for a month in the range.&lt;/LI&gt;&lt;LI&gt;Increments from start_month by (month_offset - 1) months.&lt;UL&gt;&lt;LI&gt;month_offset runs 1 to 7.&lt;/LI&gt;&lt;LI&gt;So, months generated will be: start_month + 0, +1, +2, ..., +6 months.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;This way, you get the start-of-month epoch for each month in the range.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;6. | where month_epoch &amp;lt;= end_epoch&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Filters out any months whose starting epoch is greater than now (in case the 7 generated months go slightly into the future).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;7. | eval month=strftime(month_epoch, "%b")&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Converts month_epoch into a "short month name" format (e.g., "Jan", "Feb", etc).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;8. | stats list(month) as search&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Aggregates the results into a single row, with the months as a list, titled "search".&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;This is then returned from the subsearch as a list which is consumed by the table command.&lt;/DIV&gt;&lt;DIV class=""&gt;If you ran the search by itself you would get:&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1748522004739.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39231iEE35D189A56C54DE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1748522004739.png" alt="livehybrid_0-1748522004739.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;Please let me know if you have any further questions on this! I'm really pleased to have got to the bottom of it!&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 May 2025 12:46:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-sort-the-month-fields-chronological-instead-of/m-p/747195#M241779</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-05-29T12:46:33Z</dc:date>
    </item>
  </channel>
</rss>

