<?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 How to count cumulative average by month? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546136#M154797</link>
    <description>&lt;P&gt;Hello all.&amp;nbsp; I am trying to find the average by closed_month, but I want the average duration to include events from previous months in its average.&lt;/P&gt;&lt;P&gt;So, average for Feb should include Jan + Feb.&amp;nbsp; Average for March should include Jan + Feb + Mar.&amp;nbsp; I figured out how to get the average for each month, but I don't know how to get include the previous months average_duration along with the current month.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample Table of Data&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Case    opened  closed  closed_month    duration
aaa     Jan-01  Jan-31  Jan             30
bbb     Feb-10  Feb-26  Feb             16
ccc     Feb-13  Feb-28  Feb             15
ddd     Feb-14  Feb-28  Feb             14
eee     Feb-17  Mar-01  Mar             11
fff     Feb-24  Mar-13  Mar             17
ggg     Mar-03  Mar-11  Mar             8
hhh     Mar-11  Mar-16  Mar             5
iii     Mar-22  Mar-24  Mar             2&lt;/LI-CODE&gt;&lt;P&gt;Avg Jan = (30) = 30&lt;BR /&gt;Avg Feb = (30+16+15+14)/4 = 18.8&lt;BR /&gt;Avg Mar = (30+16+15+14+11+17+8+5+2)/9 = 13.1&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The desired result is a column chart, with 3 columns, one for each resolved month.&amp;nbsp; Then each would go have the value 30, 18.8, and 13.1 respectively.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Mar 2021 06:48:25 GMT</pubDate>
    <dc:creator>kmfpo</dc:creator>
    <dc:date>2021-03-31T06:48:25Z</dc:date>
    <item>
      <title>How to count cumulative average by month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546136#M154797</link>
      <description>&lt;P&gt;Hello all.&amp;nbsp; I am trying to find the average by closed_month, but I want the average duration to include events from previous months in its average.&lt;/P&gt;&lt;P&gt;So, average for Feb should include Jan + Feb.&amp;nbsp; Average for March should include Jan + Feb + Mar.&amp;nbsp; I figured out how to get the average for each month, but I don't know how to get include the previous months average_duration along with the current month.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample Table of Data&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Case    opened  closed  closed_month    duration
aaa     Jan-01  Jan-31  Jan             30
bbb     Feb-10  Feb-26  Feb             16
ccc     Feb-13  Feb-28  Feb             15
ddd     Feb-14  Feb-28  Feb             14
eee     Feb-17  Mar-01  Mar             11
fff     Feb-24  Mar-13  Mar             17
ggg     Mar-03  Mar-11  Mar             8
hhh     Mar-11  Mar-16  Mar             5
iii     Mar-22  Mar-24  Mar             2&lt;/LI-CODE&gt;&lt;P&gt;Avg Jan = (30) = 30&lt;BR /&gt;Avg Feb = (30+16+15+14)/4 = 18.8&lt;BR /&gt;Avg Mar = (30+16+15+14+11+17+8+5+2)/9 = 13.1&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The desired result is a column chart, with 3 columns, one for each resolved month.&amp;nbsp; Then each would go have the value 30, 18.8, and 13.1 respectively.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 06:48:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546136#M154797</guid>
      <dc:creator>kmfpo</dc:creator>
      <dc:date>2021-03-31T06:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to count cumulative average by month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546139#M154798</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/173506"&gt;@kmfpo&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;in other words, you want data from the 1st of january of the current year to the last day of the previous month, is this correct?&lt;/P&gt;&lt;P&gt;If this is your need, you habe to add to your main search these time qualifiers:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;earliest=@y latest=@mon&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 06:55:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546139#M154798</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-31T06:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to count cumulative average by month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546140#M154799</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults | eval _raw="Case    opened  closed  closed_month    duration
aaa     Jan-01  Jan-31  Jan             30
bbb     Feb-10  Feb-26  Feb             16
ccc     Feb-13  Feb-28  Feb             15
ddd     Feb-14  Feb-28  Feb             14
eee     Feb-17  Mar-01  Mar             11
fff     Feb-24  Mar-13  Mar             17
ggg     Mar-03  Mar-11  Mar             8
hhh     Mar-11  Mar-16  Mar             5
iii     Mar-22  Mar-24  Mar             2"
| multikv forceheader=1
| fields - _raw _time


| streamstats sum(duration) as total count as cases
| stats max(cases) as cases max(total) as total by closed_month
| eval average=total/cases&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 31 Mar 2021 06:58:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546140#M154799</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-03-31T06:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to count cumulative average by month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546163#M154809</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/173506"&gt;@kmfpo&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;You can also use accum command to calculate the running total of duration values.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count, sum(duration) as duration, last(closed) as closed by closed_month 
| eval closed=strptime(closed, "%b-%d") 
| sort closed 
| accum duration as total_duration 
| accum count as total_count 
| eval Avg=round(total_duration/total_count, 1), temp=1, closed_month="Avg ".closed_month 
| xyseries temp, closed_month, Avg 
| fields - temp&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you, a like would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 07:59:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546163#M154809</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-03-31T07:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to count cumulative average by month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546216#M154828</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&amp;nbsp; The only thing wrong that needs adjustment is the month sorting.&amp;nbsp; It is listed as Feb, Jan, Mar (alphabetical I am guessing).&amp;nbsp; How can I force the order to be calendar order (Jan, Feb, Mar...)?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 13:45:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546216#M154828</guid>
      <dc:creator>kmfpo</dc:creator>
      <dc:date>2021-03-31T13:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to count cumulative average by month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546225#M154832</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/173506"&gt;@kmfpo&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Since the closed_month is not time, time conversion functions are not working. You can use below;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="Case    opened  closed  closed_month    duration
aaa     Jan-01  Jan-31  Jan             30
bbb     Feb-10  Feb-26  Feb             16
ccc     Feb-13  Feb-28  Feb             15
ddd     Feb-14  Feb-28  Feb             14
eee     Feb-17  Mar-01  Mar             11
fff     Feb-24  Mar-13  Mar             17
ggg     Mar-03  Mar-11  Mar             8
hhh     Mar-11  Mar-16  Mar             5
iii     Mar-22  Mar-24  Mar             2" 
| multikv forceheader=1 
| fields - _raw _time 


| streamstats sum(duration) as total count as cases 
| stats max(cases) as cases max(total) as total by closed_month 
| eval average=total/cases 
| eval month=case(
    closed_month="Jan","01",
    closed_month="Feb","02",
    closed_month="Mar","03",
    closed_month="Apr","04",
    closed_month="May","05",
    closed_month="Jun","06",
    closed_month="Jul","07",
    closed_month="Aug","08",
    closed_month="Sep","09",
    closed_month="Oct","10",
    closed_month="Nov","11",
    closed_month="Dec","12") 
| sort month
| fields - month&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 31 Mar 2021 14:18:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546225#M154832</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-03-31T14:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to count cumulative average by month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546226#M154833</link>
      <description>&lt;P&gt;You should parse the date strings to epoch time values&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval time=strptime(time, "%Y-%m-%d %H:%M:%S")&lt;/LI-CODE&gt;&lt;P&gt;or what time format you are using in your real events&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 14:19:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-cumulative-average-by-month/m-p/546226#M154833</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-03-31T14:19:01Z</dc:date>
    </item>
  </channel>
</rss>

