<?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: Display comparison between last week vs this week data  in 2 rows and calculated change in percent in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Display-comparison-between-last-week-vs-this-week-data-in-2-rows/m-p/213792#M187945</link>
    <description>&lt;P&gt;This is how I'll do this (run anywhere sample, for count of events comparison for last week vs this week, full week)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=-1w@w latest=now() | timechart span=1w count as EventCount | eval Period=if(_time=relative_time(now(),"@w"),"This Week Data","Last Week Data") | streamstats current=f window=1 values(EventCount) as prev | eval Change_Percentage=if(isnotnull(prev),(EventCount-prev)*100/prev,"NA") | table Period EventCount Change_Percentage
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample output&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Period           EventCount  Change_Percentage
Last Week Data   281386      NA 
This Week Data   1112784     295.465304 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to compare only specific timeframe of this week vs last week (like today's data vs same day last week), try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=@d latest=now | stats count as EventCount| eval Period="Today" | append [search index=_internal earliest=-8d@d latest=-7d | stats count as EventCount | eval Period="Last Week Same Day" ]  | streamstats current=f window=1 values(EventCount) as prev | eval Change_Percentage=if(isnotnull(prev),(EventCount-prev)*100/prev,"NA") | table Period EventCount Change_Percentage
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 20 Feb 2016 04:02:53 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-02-20T04:02:53Z</dc:date>
    <item>
      <title>Display comparison between last week vs this week data  in 2 rows and calculated change in percent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-comparison-between-last-week-vs-this-week-data-in-2-rows/m-p/213790#M187943</link>
      <description>&lt;P&gt;I don't know if this is possible. I am trying to compare last week data vs this week data and displayed in such a way as shown:&lt;/P&gt;

&lt;P&gt;LastWeekDate (12Feb-12:00)                         LastweekData  [ 200K]                                                    ChangeIn%&lt;BR /&gt;
ThisWeekDate  (19Feb-12:00)                        ThisweekData   [250K]                                        [25%]of lastweek&amp;amp;thisweek&lt;/P&gt;

&lt;P&gt;I do not know even this is possible but just seeing if anyone has done this.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2016 01:54:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-comparison-between-last-week-vs-this-week-data-in-2-rows/m-p/213790#M187943</guid>
      <dc:creator>abajracharya</dc:creator>
      <dc:date>2016-02-20T01:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Display comparison between last week vs this week data  in 2 rows and calculated change in percent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-comparison-between-last-week-vs-this-week-data-in-2-rows/m-p/213791#M187944</link>
      <description>&lt;P&gt;Here's my query which compares tax errors in the previous hour vs yesterdays previous hour and alerts if the errors in the previous hour were 25% higher than the previous hour of yesterday&lt;/P&gt;

&lt;P&gt;So to answer your question, yes it's possible. You will need to use a subsearch which will look at yesterdays house and your main search will look back the previous hour&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vertex7-access   RTG_Error="500" earliest=-1h@h latest=@h                           
| append [| noop | stats count AS RTG_Tax | eval RTG_Tax = "LookupTaxAreas70"]          
| append [| noop | stats count AS RTG_Tax | eval RTG_Tax = "CalculateTax70"]
| stats count AS TodayLastHour by RTG_Tax          
| eval TodayLastHour = TodayLastHour - if((RTG_Tax = "LookupTaxAreas70"), 1, 0)   
| eval TodayLastHour = TodayLastHour - if((RTG_Tax = "CalculateTax70"), 1, 0)
| addtotals col=t row=f labelfield=RTG_Tax label=Total
| appendcols [search index=vertex7-access RTG_Error="500" earliest=-25h@h latest=-24h@h   
| append [| noop | stats count AS RTG_Tax | eval RTG_Tax = "LookupTaxAreas70"] 
| append [| noop | stats count AS RTG_Tax | eval RTG_Tax = "CalculateTax70"] 
| stats count AS YesterdayLastHour by RTG_Tax    
| eval YesterdayLastHour = YesterdayLastHour - if((RTG_Tax = "LookupTaxAreas70"), 1, 0)  
| eval YesterdayLastHour = YesterdayLastHour - if((RTG_Tax = "CalculateTax70"), 1, 0)   
| addtotals col=t row=f labelfield=RTG_Tax label=Total   
| table RTG_Tax, YesterdayLastHour | rename RTG_Tax AS Total]
| rename RTG_Tax AS Total 
| where TodayLastHour &amp;gt;  1.25 * YesterdayLastHour
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Feb 2016 02:51:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-comparison-between-last-week-vs-this-week-data-in-2-rows/m-p/213791#M187944</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-02-20T02:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Display comparison between last week vs this week data  in 2 rows and calculated change in percent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-comparison-between-last-week-vs-this-week-data-in-2-rows/m-p/213792#M187945</link>
      <description>&lt;P&gt;This is how I'll do this (run anywhere sample, for count of events comparison for last week vs this week, full week)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=-1w@w latest=now() | timechart span=1w count as EventCount | eval Period=if(_time=relative_time(now(),"@w"),"This Week Data","Last Week Data") | streamstats current=f window=1 values(EventCount) as prev | eval Change_Percentage=if(isnotnull(prev),(EventCount-prev)*100/prev,"NA") | table Period EventCount Change_Percentage
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample output&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Period           EventCount  Change_Percentage
Last Week Data   281386      NA 
This Week Data   1112784     295.465304 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to compare only specific timeframe of this week vs last week (like today's data vs same day last week), try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=@d latest=now | stats count as EventCount| eval Period="Today" | append [search index=_internal earliest=-8d@d latest=-7d | stats count as EventCount | eval Period="Last Week Same Day" ]  | streamstats current=f window=1 values(EventCount) as prev | eval Change_Percentage=if(isnotnull(prev),(EventCount-prev)*100/prev,"NA") | table Period EventCount Change_Percentage
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Feb 2016 04:02:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-comparison-between-last-week-vs-this-week-data-in-2-rows/m-p/213792#M187945</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-20T04:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Display comparison between last week vs this week data  in 2 rows and calculated change in percent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-comparison-between-last-week-vs-this-week-data-in-2-rows/m-p/213793#M187946</link>
      <description>&lt;P&gt;Thanks somesoni2. i was actually looking for second scenario and it worked good. &lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2016 17:36:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-comparison-between-last-week-vs-this-week-data-in-2-rows/m-p/213793#M187946</guid>
      <dc:creator>abajracharya</dc:creator>
      <dc:date>2016-02-20T17:36:31Z</dc:date>
    </item>
  </channel>
</rss>

