<?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: Add a count from a different time period in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Add-a-count-from-a-different-time-period/m-p/569710#M198559</link>
    <description>&lt;P&gt;hello and thanks a lot for the continuous help,&lt;/P&gt;&lt;P&gt;I'm going to test this query tomorrow. it looks like the right thing we need. will keep you updated and thanks again!&lt;/P&gt;</description>
    <pubDate>Tue, 05 Oct 2021 14:37:44 GMT</pubDate>
    <dc:creator>avoelk</dc:creator>
    <dc:date>2021-10-05T14:37:44Z</dc:date>
    <item>
      <title>Add a count from a different time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-count-from-a-different-time-period/m-p/566452#M197406</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to add the appearance of a certain value in my base search count. the value is "detatched". it is written in an event, when a certain license has been used. this detatched license has a lifespan of 14 days, afterwards it's not active anymore and I don't need to add this to my base search anymore.&lt;/P&gt;&lt;P&gt;so basically it's like this :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;index=indexa=* licensecount=* productid=5000 earliest=-30d@d latest=now()&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;| eval flag="basecount"&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;| append&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;[search index=indexa =*&amp;nbsp; productid=5000 subject="*detatched*" earliest=-45d@d latest=-31d@d&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;| eval flag="addcount"]&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;| stats count(eval(flag="basecount")) as basecount count(eval(flag="addcount")) as addcount&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;| eval totalcount = basecount+addcount&lt;BR /&gt;|timechart span=1d count(totalcount)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;I know this query is partlially stupid but what I want to show is what I'm trying to accomplish. Example: Today I have a licence count of the product 5000 of 5, 14 days ago I had a count of 1, therefore today it should show me 6. tomorrow, this count of 1 shouldn't be added anymore, cause it's more than 14 days old and not active anymore. this should be seen - ideally - in a timechart.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Hope someone can make sense of this . Much appreciate any help or feedback, cause, maybe it's not possible to do so in splunk.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot guys&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 12:53:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-count-from-a-different-time-period/m-p/566452#M197406</guid>
      <dc:creator>avoelk</dc:creator>
      <dc:date>2021-09-09T12:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Add a count from a different time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-count-from-a-different-time-period/m-p/566457#M197411</link>
      <description>&lt;P&gt;Hi again&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/228376"&gt;@avoelk&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;So resuming where we left it here:&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/search-a-value-in-previous-time-period-and-add-to-current-count/m-p/566103," target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/search-a-value-in-previous-time-period-and-add-to-current-count/m-p/566103,&lt;/A&gt;&amp;nbsp;I would try the following (keep in mind there might be typos as I did not test this on any lab):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=indexa licensecount=* earliest=-45d@d latest=now()
| stats 
    count(eval(if(_time &amp;gt;= relative_time(now(), "-30d@d"), 1, null())))) as basecount,
    count(eval(if(_time &amp;gt;= relative_time(now(), "-45d@d") AND _time &amp;lt; relative_time(now(), "-30d@d") AND match(subject, "detatched"), 1, null())))) as addcount by productid
| eval totalcount = basecount + addcount
| timechart span=1d count(totalcount) by productid&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 13:36:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-count-from-a-different-time-period/m-p/566457#M197411</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2021-09-09T13:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add a count from a different time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-count-from-a-different-time-period/m-p/569710#M198559</link>
      <description>&lt;P&gt;hello and thanks a lot for the continuous help,&lt;/P&gt;&lt;P&gt;I'm going to test this query tomorrow. it looks like the right thing we need. will keep you updated and thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 14:37:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-count-from-a-different-time-period/m-p/569710#M198559</guid>
      <dc:creator>avoelk</dc:creator>
      <dc:date>2021-10-05T14:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Add a count from a different time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-count-from-a-different-time-period/m-p/570007#M198680</link>
      <description>&lt;P&gt;Hello and thank you for your help,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after further discussion I think the best way of putting it is the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.)&lt;/P&gt;&lt;P&gt;I need a maximum of a value of a certain attribute at a specific day as basecount and then looks back 14 days (related to this specific day) and counts the occurance of events which contain the word "detatched" and add this as a count to the basecount.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.)&lt;/P&gt;&lt;P&gt;this would be the view for a specific day. after this I'd need this view, but for a timewindow of for example 7 days (sliding timewindow).&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's the best way of finally putting it. I hope you get what I mean. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I'm sorry that I switched back and forth with the explanation but as you can see it's not an easy way of describing it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for the help!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 08:25:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-count-from-a-different-time-period/m-p/570007#M198680</guid>
      <dc:creator>avoelk</dc:creator>
      <dc:date>2021-10-07T08:25:59Z</dc:date>
    </item>
  </channel>
</rss>

