<?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: How to modify my search to include historic count to my current day's count and also average? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247732#M73899</link>
    <description>&lt;P&gt;Hi pavanae,&lt;BR /&gt;
if you run separately the two searches, have you the expected results?&lt;BR /&gt;
you should find the two searches that satisfy you need and then join them using appendpipe.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Tue, 29 Nov 2016 09:29:18 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2016-11-29T09:29:18Z</dc:date>
    <item>
      <title>How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247724#M73891</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;

&lt;P&gt;I have a search as follows which displays the usernames, their accessing application count on that day, and the average of total users average accessing application count &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype = foo | | stats dc(A) as accessing_application_count by usernames |eventstats avg(accessing_application_count) as avg_accessing_application_count |stats max(accessing_application_count) as max_accessing_application_count max(avg_accessing_application_count) as avg_accessing_application_count by usernames
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which Displays something as follows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;usernames   max_accessing_application_count avg_accessing_application_count
abc                             3                      4.982456
def                             0                      4.982456
ghi                               10                       4.982456
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to calculate similarly for each user's last 3 days &lt;STRONG&gt;max_accessing_application_count&lt;/STRONG&gt; which should be calculated based on each day's  &lt;STRONG&gt;max_accessing_application_count&lt;/STRONG&gt; of last 3 days, and the average too. like below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;usernames  max_accessing_application_count  last_3days_max_accessing_  avg_accessing_application_count  last_7d_avg
abc        3                                6                          4.982456                         7.8
def        0                                4                          4.982456                         7.8
ghi        10                              7                          4.982456                         7.8
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;average should be calculated as each days average for the last 3 days and that 3 days average of that.&lt;/P&gt;

&lt;P&gt;Please suggest if you have any idea to help me regarding this query. &lt;/P&gt;

&lt;P&gt;Updated :-&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/173313-not-worked.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:56:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247724#M73891</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2020-09-29T11:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247725#M73892</link>
      <description>&lt;P&gt;Have you seen simple moving averages before?&lt;/P&gt;

&lt;P&gt;... | trendline sma3(FieldName)&lt;/P&gt;

&lt;P&gt;Above would give you the average of the last 3 days for FieldName on a trendline.  But that's probably not what you're looking for.&lt;/P&gt;

&lt;P&gt;... | streamstats window=3 avg(FieldName) as Sma3_FieldName | ...&lt;/P&gt;

&lt;P&gt;Would probably do the trick for you though.  You just need a couple of those and then x days worth of data.  Take it all to a stats, table or chart.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 13:24:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247725#M73892</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-11-27T13:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247726#M73893</link>
      <description>&lt;P&gt;Thank you for the response. haven't tried the trendline before But seen no results while I'm trying. I just added the streamstats as suggested after my query like below&lt;/P&gt;

&lt;P&gt;earliest=-3d@d latest=@d My query...| streamstats window=3 avg(accessing_application_count) as Sma3_accessing_application_count | table usernames max_accessing_application_count avg_accessing_application_count Sma3_accessing_application_count&lt;/P&gt;

&lt;P&gt;Please correct me. &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/199197"&gt;@jkat54&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:56:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247726#M73893</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2020-09-29T11:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247727#M73894</link>
      <description>&lt;P&gt;How about this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-3d@d latest=now index=foo sourcetype = foo 
| eval oneday=if(_time&amp;gt;relative_time(now(),"@d"),A,null())
| eval threeday=if(_time&amp;lt;relative_time(now(),"@d"),A,null())
| stats dc(oneday) as accessing_application_count dc(threeday) as last_3days_accessing_count by usernames
|eventstats avg(accessing_application_count) as avg_accessing_application_count avg(last_3days_accessing_count) as avg_last_3days_accessing_count |stats max(accessing_application_count) as max_accessing_application_count max(avg_accessing_application_count) as avg_accessing_application_count max(last_3days_accessing_count) as max_last_3days_accessing_count max(avg_last_3days_accessing_count) as avg_last_3days_accessing_count by usernames
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Nov 2016 05:05:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247727#M73894</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-11-28T05:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247728#M73895</link>
      <description>&lt;P&gt;Welcome back!!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 05:08:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247728#M73895</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-28T05:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247729#M73896</link>
      <description>&lt;P&gt;Hi pavanae,&lt;/P&gt;

&lt;P&gt;try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype = foo 
|  stats dc(A) as accessing_application_count by usernames 
| eventstats avg(accessing_application_count) as avg_accessing_application_count 
| stats max(accessing_application_count) as max_accessing_application_count max(avg_accessing_application_count) as avg_accessing_application_count by usernames
| appendpipe [ search
   index=foo sourcetype = foo earliest=-3d@d latest=now 
   |  stats dc(A) as accessing_application_count by usernames 
   | eventstats avg(accessing_application_count) as avg_accessing_application_count 
   | stats max(accessing_application_count) as last_3days_max_accessing_count max(avg_accessing_application_count) as last_3days_avg_accessing_application_count by usernames
   ]
| table username max_accessing_application_count  last_3days_max_accessing_count avg_accessing_application_count last_3days_avg_accessing_application_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 08:36:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247729#M73896</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-11-28T08:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247730#M73897</link>
      <description>&lt;P&gt;for some reason I'm seeing all the dayone data as zero. @somesoni2 Updated in the question.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 15:46:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247730#M73897</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2016-11-28T15:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247731#M73898</link>
      <description>&lt;P&gt;Thanks for the response @cusello. no results found with the query. also given a pipe before the appendcols, added the command "search" at the beginning of the search still no results or incomplete results.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 20:19:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247731#M73898</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2016-11-28T20:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247732#M73899</link>
      <description>&lt;P&gt;Hi pavanae,&lt;BR /&gt;
if you run separately the two searches, have you the expected results?&lt;BR /&gt;
you should find the two searches that satisfy you need and then join them using appendpipe.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 09:29:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247732#M73899</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-11-29T09:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247733#M73900</link>
      <description>&lt;P&gt;try join type=outer &lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 09:35:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247733#M73900</guid>
      <dc:creator>puneethgowda</dc:creator>
      <dc:date>2016-11-29T09:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to include historic count to my current day's count and also average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247734#M73901</link>
      <description>&lt;P&gt;My answer is running on time range &lt;CODE&gt;earliest=-3d@d latest=now&lt;/CODE&gt; and field avg_accessing_application_count and max_accessing_application_count is showing data for today (using &lt;CODE&gt;_time&amp;gt;relative_time(now(),"@d")&lt;/CODE&gt; in eval ). If you're running with different time range, you might see 0 for dayone data. Check that.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:57:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-include-historic-count-to-my-current/m-p/247734#M73901</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T11:57:02Z</dc:date>
    </item>
  </channel>
</rss>

