<?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: ticket count every open months in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331367#M98596</link>
    <description>&lt;P&gt;Sample:&lt;/P&gt;

&lt;P&gt;TICKET NO.   Created date   Resolved date&lt;BR /&gt;
Ticket-1            |  2017 / 06   |   2017 / 09&lt;BR /&gt;
Ticket-2            |  2017 / 01   |   2017 / 04&lt;BR /&gt;
Ticket-3            |  2017 / 02   |   2017 / 05&lt;BR /&gt;
Ticket-4            |  2017 / 03   |   2017 / 06&lt;BR /&gt;
Ticket-5            |  2017 / 05   |   2017 / 08&lt;/P&gt;

&lt;P&gt;When i do statistics for the 5 tickets above the result is:&lt;/P&gt;

&lt;P&gt;Ticket 1: will only be counted in June(06) and September(09), created and resolved dates respectively&lt;BR /&gt;
Ticket 2: will only be counted in January(01) and Apr(04), created and resolved dates respectively&lt;BR /&gt;
Ticket 3: will only be counted in Feb(02) and May(05), created and resolved dates respectively&lt;BR /&gt;
Ticket 4: will only be counted in March(03) and Jun(06), created and resolved dates respectively&lt;BR /&gt;
Ticket 5: will only be counted in May(05) and Aug(08), created and resolved dates respectively&lt;/P&gt;

&lt;P&gt;For ticket 1 i want it to be counted as well in July and August because it was only resolved on Sept.&lt;BR /&gt;
Same logic with others.&lt;/P&gt;

&lt;P&gt;What i want my statistics to look like:&lt;/P&gt;

&lt;P&gt;Year-month          =    Count&lt;BR /&gt;
2017-January    =   1&lt;BR /&gt;&lt;BR /&gt;
2017-February   =   2&lt;BR /&gt;
2017-March  =   3&lt;BR /&gt;
2017-April  =   3&lt;BR /&gt;
2017-may    =   3&lt;BR /&gt;
2017-June   =   3&lt;BR /&gt;
2017-July   =   2&lt;BR /&gt;
2017-August =   2&lt;BR /&gt;
2017-September  =   1&lt;BR /&gt;
2017-October    =   0&lt;BR /&gt;
2017-November   =   0&lt;BR /&gt;
2017-December   =   0&lt;/P&gt;

&lt;P&gt;then doing the timechart&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jul 2017 12:48:13 GMT</pubDate>
    <dc:creator>jonathan_yan5</dc:creator>
    <dc:date>2017-07-27T12:48:13Z</dc:date>
    <item>
      <title>ticket count every open months</title>
      <link>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331365#M98594</link>
      <description>&lt;P&gt;how can i count "several" tickets as "OPEN" every month including when it was created(create_date, mmddyyyy) to the month it was resolved(mmddyyyy), only given values are open date and resolve date. the ticket record is not found in between the months of created and resolved dates.&lt;/P&gt;

&lt;P&gt;Chart visualization should be like a timechart&lt;/P&gt;

&lt;P&gt;example:&lt;BR /&gt;
ticket 1 : created(07202016), resolved(09222016) -&amp;gt; should be counted in July, august, september months as OPEN&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:57:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331365#M98594</guid>
      <dc:creator>jonathan_yan5</dc:creator>
      <dc:date>2017-07-27T07:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: ticket count every open months</title>
      <link>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331366#M98595</link>
      <description>&lt;P&gt;Could you share some sample events?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 12:24:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331366#M98595</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-27T12:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: ticket count every open months</title>
      <link>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331367#M98596</link>
      <description>&lt;P&gt;Sample:&lt;/P&gt;

&lt;P&gt;TICKET NO.   Created date   Resolved date&lt;BR /&gt;
Ticket-1            |  2017 / 06   |   2017 / 09&lt;BR /&gt;
Ticket-2            |  2017 / 01   |   2017 / 04&lt;BR /&gt;
Ticket-3            |  2017 / 02   |   2017 / 05&lt;BR /&gt;
Ticket-4            |  2017 / 03   |   2017 / 06&lt;BR /&gt;
Ticket-5            |  2017 / 05   |   2017 / 08&lt;/P&gt;

&lt;P&gt;When i do statistics for the 5 tickets above the result is:&lt;/P&gt;

&lt;P&gt;Ticket 1: will only be counted in June(06) and September(09), created and resolved dates respectively&lt;BR /&gt;
Ticket 2: will only be counted in January(01) and Apr(04), created and resolved dates respectively&lt;BR /&gt;
Ticket 3: will only be counted in Feb(02) and May(05), created and resolved dates respectively&lt;BR /&gt;
Ticket 4: will only be counted in March(03) and Jun(06), created and resolved dates respectively&lt;BR /&gt;
Ticket 5: will only be counted in May(05) and Aug(08), created and resolved dates respectively&lt;/P&gt;

&lt;P&gt;For ticket 1 i want it to be counted as well in July and August because it was only resolved on Sept.&lt;BR /&gt;
Same logic with others.&lt;/P&gt;

&lt;P&gt;What i want my statistics to look like:&lt;/P&gt;

&lt;P&gt;Year-month          =    Count&lt;BR /&gt;
2017-January    =   1&lt;BR /&gt;&lt;BR /&gt;
2017-February   =   2&lt;BR /&gt;
2017-March  =   3&lt;BR /&gt;
2017-April  =   3&lt;BR /&gt;
2017-may    =   3&lt;BR /&gt;
2017-June   =   3&lt;BR /&gt;
2017-July   =   2&lt;BR /&gt;
2017-August =   2&lt;BR /&gt;
2017-September  =   1&lt;BR /&gt;
2017-October    =   0&lt;BR /&gt;
2017-November   =   0&lt;BR /&gt;
2017-December   =   0&lt;/P&gt;

&lt;P&gt;then doing the timechart&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 12:48:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331367#M98596</guid>
      <dc:creator>jonathan_yan5</dc:creator>
      <dc:date>2017-07-27T12:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: ticket count every open months</title>
      <link>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331368#M98597</link>
      <description>&lt;P&gt;Hi jonathan_yan5, I know the following does not give you what you asked but I feel Timeline Custom Visualization (&lt;A href="https://splunkbase.splunk.com/app/3120/"&gt;https://splunkbase.splunk.com/app/3120/&lt;/A&gt;) is a better match for your use case as compared to Timechart.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3262iBD76E952DCA93CB0/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
Following is a run anywhere search which mocks that sample data you have provided and then converts Date to Epoch Time to calculate duration of ticket resolution.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;viz type="timeline_app.timeline"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
| eval data="Ticket-1 | 2017 / 06 | 2017 / 09;Ticket-2 | 2017 / 01 | 2017 / 04;Ticket-3 | 2017 / 02 | 2017 / 05;Ticket-4 | 2017 / 03 | 2017 / 06;Ticket-5 | 2017 / 05 | 2017 / 08"
| fields - _time
| makemv delim=";" data
| mvexpand data
| eval mvData=split(data,"|")
| eval TICKET_NO=mvindex(mvData,0)
| eval Created_date=strptime(replace(mvindex(mvData,1),"(\d{4}) \/ (\d{2})","01/\2/\1"),"%d/%m/%Y")
| eval Resolved_date=strptime(replace(mvindex(mvData,2),"(\d{4}) \/ (\d{2})","01/\2/\1"),"%d/%m/%Y")
| fields - data mvData
| eval _time= Created_date
| eval duration = (Resolved_date-Created_date) * 1000
| table _time TICKET_NO duration&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="timeline_app.timeline.axisTimeFormat"&amp;gt;DAYS&amp;lt;/option&amp;gt;
        &amp;lt;option name="timeline_app.timeline.colorMode"&amp;gt;categorical&amp;lt;/option&amp;gt;
        &amp;lt;option name="timeline_app.timeline.maxColor"&amp;gt;#DA5C5C&amp;lt;/option&amp;gt;
        &amp;lt;option name="timeline_app.timeline.minColor"&amp;gt;#FFE8E8&amp;lt;/option&amp;gt;
        &amp;lt;option name="timeline_app.timeline.numOfBins"&amp;gt;6&amp;lt;/option&amp;gt;
        &amp;lt;option name="timeline_app.timeline.tooltipTimeFormat"&amp;gt;DAYS&amp;lt;/option&amp;gt;
        &amp;lt;option name="timeline_app.timeline.useColors"&amp;gt;0&amp;lt;/option&amp;gt;
        &amp;lt;option name="trellis.enabled"&amp;gt;0&amp;lt;/option&amp;gt;
        &amp;lt;option name="trellis.scales.shared"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="trellis.size"&amp;gt;medium&amp;lt;/option&amp;gt;
      &amp;lt;/viz&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jul 2017 18:35:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331368#M98597</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-27T18:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: ticket count every open months</title>
      <link>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331369#M98598</link>
      <description>&lt;P&gt;Here's another way of looking at it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your search that for each ticket gets created and resolved in mmddyyyy format

| rename COMMENT as "Change created and resolved into epoch time
| eval CreatedEpoch=strptime(created,"%m%d%Y") 
| eval ResolvedEpoch=strptime(resolved,"%m%d%Y")

| rename COMMENT as "Format created and resolved dates as/of the start of their month, add a month to the resolved date because thats when we reduce the count."
| eval openMonth=relative_time(CreatedEpoch,"@mon")
| eval closeMonth=relative_time(ResolvedEpoch,"+1mon@mon")

| rename COMMENT as "Release one +1 record for the open and one -1 for the close."
| eval mytimes=mvappend("openMonth=".openMonth, "closeMonth=".closeMonth)
| table mytimes
| mvexpand mytimes
| rex field=mytimes "^(?&amp;lt;TheMonth&amp;gt;[^=]+)=(?&amp;lt;TheTime&amp;gt;.+)$"
| rename TheTime as _time
| eval OpenCount=if(TheMonth="openMonth",1,-1)

| rename COMMENT as "Now we sum it all up."
| stats sum(OpenCount) as OpenCount by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You need to pull all events that are not yet closed at the beginning of the first month, or which have already been opened by the end of the last month,  then kill all summary records before the beginning of the period you are interested in or after the end of the period.  If you need any help with that logic, just let us know&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 21:56:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331369#M98598</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-27T21:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: ticket count every open months</title>
      <link>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331370#M98599</link>
      <description>&lt;P&gt;Hi Daljeanis,&lt;BR /&gt;
thank you for your script.&lt;BR /&gt;
i have tried using it but the year is 1970, also the months a ticket should be opened is not correct. &lt;/P&gt;

&lt;P&gt;Please take note of this example:&lt;/P&gt;

&lt;P&gt;"ticket AAA" is created june2017 and resolved Sept2017&lt;BR /&gt;
therefore months june, july, august, and september should have an open ticket count of 1.&lt;BR /&gt;
that makes it:&lt;/P&gt;

&lt;P&gt;june = 1&lt;BR /&gt;
july = 1&lt;BR /&gt;
aug=1&lt;BR /&gt;
sept = 1 ("ticket AAA" is open for some of the days in sept so i counted it also as open on the resolve date)&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 02:12:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/ticket-count-every-open-months/m-p/331370#M98599</guid>
      <dc:creator>jonathan_yan5</dc:creator>
      <dc:date>2017-07-31T02:12:42Z</dc:date>
    </item>
  </channel>
</rss>

