<?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 compare the last 7 days' average with yesterday's average? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231998#M68832</link>
    <description>&lt;P&gt;I updated the query to fix the error. Try it now.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Nov 2016 13:35:55 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-11-18T13:35:55Z</dc:date>
    <item>
      <title>How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231991#M68825</link>
      <description>&lt;P&gt;I have a Splunk search as below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-1d@d latest=@d index="abc" sourcetype="def" | stats earliest(date_hour) as FirstHour  latest(date_hour) as LastHour by student | eval accessTimerange=FirstHour+" -- "+LastHour | fields  - FirstHour - LastHour   | table student accessTimerange
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which Displays the results as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;student     accessTimerange
A123        22--24   
B456        02--08
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, how can I modify my search to Compare  last 7 days' average accessTimerange with yesterday's accessTimerange&lt;/P&gt;

&lt;P&gt;Hint: average of accessTimerange is average of earliest(date_hour) and latest(date_hour) for each day in last 7 days.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:50:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231991#M68825</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2020-09-29T11:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231992#M68826</link>
      <description>&lt;P&gt;This assumed "yesterday" is included in the last 7 days. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-7d@d latest=@d index="abc" sourcetype="def" | eval when=if(_time&amp;gt;relative_time(now(), "-1d@d") AND _time&amp;lt;relative_time(now(), "@d"), "Yesterday", "Last 7 days") | stats earliest(date_hour) as 7d_FirstHour  latest(date_hour) as 7d_LastHour earliest(eval(if(when="Yesterday", date_hour, null()))) as yesterday_FirstHour latest(eval(if(when="Yesterday", date_hour, null()))) as yesterday_LastHour by student | eval 7d_accessTimerange=7d_FirstHour+" -- "+7d_LastHour | eval Yesterday_accessTimerange=yesterday_FirstHour+" -- "+yesterday_LastHour |  fields  - FirstHour - LastHour   | table student 7d_accessTimerange Yesterday_accessTimerange
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;*&lt;STRONG&gt;&lt;EM&gt;UPDATED&lt;/EM&gt;&lt;/STRONG&gt;*&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval days=round((now()-_time)/86400, 0) | eval when=if(_time&amp;gt;relative_time(now(), "-1d@d") AND _time&amp;lt;relative_time(now(), "@d"), "Yesterday", "Last 7 days") | stats earliest(_time) as e latest(_time) as l by user days | stats avg(e) as a_e avg(l) as a_l values(eval(if(days=1, e, null()))) as y_e values(eval(if(days=1, l, null()))) as y_l by user | convert ctime(a*) timeformat="%H:%M"  | convert ctime(y*) timeformat="%H:%M" | eval 7d=a_e."--".a_l | eval yd=y_e."--".y_l | table user 7d yd
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Nov 2016 21:33:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231992#M68826</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-11-17T21:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231993#M68827</link>
      <description>&lt;P&gt;Thank you very much and Could you please explain. what have done in the above search to just understand the query..Also have'nt seen any results under 7d_accessTimerange.. @sundareshr&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 21:51:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231993#M68827</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2016-11-17T21:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231994#M68828</link>
      <description>&lt;P&gt;Here's the breakdown of the SPL&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-7d@d latest=@d index="abc" sourcetype="def" - retrieves last 7 days' data

| eval when=if(_time&amp;gt;relative_time(now(), "-1d@d") AND _time&amp;lt;relative_time(now(), "@d"), "Yesterday", "Last 7 days")  - checks the _time value for each event, if its greater than midnight yesterday (relative_time(now(), "-1d@d") AND less than midnight today (relative_time(now, "@d"), then set the value of when to "Yesterday", else sets it to "Last 7 days"

| stats earliest(date_hour) as 7d_FirstHour latest(date_hour) as 7d_LastHour  -  get the earliest and latest _time values for all data.

earliest(eval(if(when="Yesterday", date_hour, null()))) as yesterday_FirstHour latest(eval(if(when="Yesterday", date_hour, null()))) as yesterday_LastHour by student  - gets earliest and latest date_hour values for events where when="Yesterday"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Nov 2016 02:11:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231994#M68828</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-11-18T02:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231995#M68829</link>
      <description>&lt;P&gt;haven't seen any results for the field  "7d_accessTimerange" could you please check if anything wrong&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 04:06:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231995#M68829</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2016-11-18T04:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231996#M68830</link>
      <description>&lt;P&gt;| stats earliest(date_hour) as 7d_FirstHour latest(date_hour) as 7d_LastHour  -  get the earliest and latest _time values for all data.&lt;/P&gt;

&lt;P&gt;If I am correct From the above query it's displaying the earliest and latest time for all the 7 days. But I am looking for the average earliest time and average latest time for all the 7 days. which is average of day 1 to day 7. Please suggest how to modify the query to get like that.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:53:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231996#M68830</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2020-09-29T11:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231997#M68831</link>
      <description>&lt;P&gt;| stats earliest(date_hour) as 7d_FirstHour latest(date_hour) as 7d_LastHour  -  get the earliest and latest _time values for all data.&lt;/P&gt;

&lt;P&gt;If I am correct From the above query it's displaying the earliest and latest time for all the 7 days. But I am looking for the average earliest time and average latest time for all the 7 days. which is average of day 1 to day 7. Please suggest how to modify the query to get like that.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:53:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231997#M68831</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2020-09-29T11:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231998#M68832</link>
      <description>&lt;P&gt;I updated the query to fix the error. Try it now.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 13:35:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231998#M68832</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-11-18T13:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231999#M68833</link>
      <description>&lt;P&gt;Try the UPDATED query.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 13:46:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/231999#M68833</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-11-18T13:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/232000#M68834</link>
      <description>&lt;P&gt;Thank you very much. @sundareshr . I would really appriciate if you can also provide me how to display a chart which shows stdev of yesterday's time while compared with the last 7 days average(add stdev to the updated Query. )&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 19:16:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/232000#M68834</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2016-11-18T19:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/232001#M68835</link>
      <description>&lt;P&gt;Your time table has 2 values - start &amp;amp; end. What is stdev calculated on?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 20:24:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/232001#M68835</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-11-18T20:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the last 7 days' average with yesterday's average?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/232002#M68836</link>
      <description>&lt;P&gt;on both. something like if a user start and end time deviation.  @sundareshr&lt;/P&gt;</description>
      <pubDate>Sun, 20 Nov 2016 23:33:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-last-7-days-average-with-yesterday-s-average/m-p/232002#M68836</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2016-11-20T23:33:56Z</dc:date>
    </item>
  </channel>
</rss>

