<?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: Compare value with the value of the previous week in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542859#M153773</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232038"&gt;@exchanger&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Sorry: my error!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Your_search earliest=-14d latest=now
| eval week=if(now()-_time&amp;lt;604800,"This week","Last week")
| stats count By week&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Mar 2021 16:10:30 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2021-03-08T16:10:30Z</dc:date>
    <item>
      <title>Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542832#M153764</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to compare the value of the week before last with the value of my search (last week) and put the percentage growth/decrease in the result.&lt;BR /&gt;Currently I can display the value of the previous week to me and in another search the value of the week before last. However, I cannot compare the two values.&lt;BR /&gt;My query looks like this:&lt;BR /&gt;&lt;STRONG&gt;In search I set last week&lt;/STRONG&gt;&lt;BR /&gt;"..." | stats count as lastweek | append [search"..." earliest=-14d latest=-7d | stats count as lastweek1&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;Lastweek&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lastweek1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XX&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; XX&lt;/P&gt;&lt;P&gt;Desired Result:&lt;/P&gt;&lt;P&gt;Lastweek&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lastweek1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Change&lt;/P&gt;&lt;P&gt;XX&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;XX&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50%&lt;BR /&gt;This gives me two values, but I can't compare them, at least I don't know how. Of course it would be even more elegant if I had the value already in the first query without having to use append. Is there a solution, that I have the values of the previous week in the same query, so that I can compare both values?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 14:57:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542832#M153764</guid>
      <dc:creator>exchanger</dc:creator>
      <dc:date>2021-03-08T14:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542835#M153766</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232038"&gt;@exchanger&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you have to identify the week in your search using the eval command:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Your_search earliest=-14d latest=now
| eval week=if(_time-now()&amp;lt;604800,"This week","Last week")
| stats count By week&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 14:34:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542835#M153766</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-08T14:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542838#M153767</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="exchanger_0-1615214385258.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/13217i08BAE7FCE0D6E60F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="exchanger_0-1615214385258.png" alt="exchanger_0-1615214385258.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;So I get then only one result (see screenshot)&lt;BR /&gt;The goal would be&lt;BR /&gt;Last week&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Week before Last week&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Change&lt;BR /&gt;50&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xx%&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 14:41:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542838#M153767</guid>
      <dc:creator>exchanger</dc:creator>
      <dc:date>2021-03-08T14:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542855#M153771</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232038"&gt;@exchanger&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;which time period did you used in your search?&lt;/P&gt;&lt;P&gt;You need at least 2 weeks.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 15:48:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542855#M153771</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-08T15:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542858#M153772</link>
      <description>&lt;P&gt;Hi, there I can set what I want. But maybe I understand your question or answer wrong.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="exchanger_0-1615219304231.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/13221i3AA2ED830EC8DC44/image-size/medium?v=v2&amp;amp;px=400" role="button" title="exchanger_0-1615219304231.png" alt="exchanger_0-1615219304231.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 16:01:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542858#M153772</guid>
      <dc:creator>exchanger</dc:creator>
      <dc:date>2021-03-08T16:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542859#M153773</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232038"&gt;@exchanger&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Sorry: my error!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Your_search earliest=-14d latest=now
| eval week=if(now()-_time&amp;lt;604800,"This week","Last week")
| stats count By week&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 16:10:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542859#M153773</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-08T16:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542867#M153777</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, so I get both values. However, if I want to put them in a ratio, I don't know how that should work. Because I don't have two variables but the variable "week" which has two values.&lt;BR /&gt;Or is there a way with your command to calculate the increase/decrease from the second to the last week?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 16:55:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542867#M153777</guid>
      <dc:creator>exchanger</dc:creator>
      <dc:date>2021-03-08T16:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542872#M153779</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232038"&gt;@exchanger&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;use eval inside stats command:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Your_search earliest=-14d latest=now
| eval week=if(now()-_time&amp;lt;604800,"This week","Last week")
| stats count(eval(week="This week")) AS "This week" count(eval(week="Last week")) AS "Last week"&lt;/LI-CODE&gt;&lt;P&gt;so you have two values on the same row and you can calculate a percentage.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 17:09:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542872#M153779</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-08T17:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542881#M153782</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much. Now I can also put these in relation. However, I still have one last question. Apart from stats count, I am also asking avg, max etc. So the command looks like this :&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;stats count(eval(week="This week")) AS "This week" count(eval(week="Last week")) AS "Last week"&lt;STRONG&gt;, avg(DURATION) as AVG, max(DURATION) as MAX&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I want to have the comparison from the last week to the week before last not only for stats count but also for AVG max etc. I am not sure how to change the command avg(DURATION) to give me the data from last week and how to change it to give me the data from the week before last. Since I have already defined "Last week" and "this week" I would probably have to put them in the brackets "(DURATION"), I just wonder how?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 18:15:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542881#M153782</guid>
      <dc:creator>exchanger</dc:creator>
      <dc:date>2021-03-08T18:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542966#M153808</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232038"&gt;@exchanger&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Your_search earliest=-14d latest=now
| eval week=if(now()-_time&amp;lt;604800,"This week","Last week")
| stats 
     count(eval(week="This week")) AS "Count this week" 
     count(eval(week="Last week")) AS "Count last week" 
     avg(eval(if(week="This week",DURATION,"")) AS "AVG this week" 
     avg(eval(if(week="Last week",DURATION,"")) AS "AVG last week"&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 08:13:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/542966#M153808</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-09T08:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Compare value with the value of the previous week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/543006#M153818</link>
      <description>&lt;P&gt;hI&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232038"&gt;@exchanger&lt;/a&gt;&lt;/P&gt;&lt;P&gt;good for you!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 11:34:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-value-with-the-value-of-the-previous-week/m-p/543006#M153818</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-09T11:34:38Z</dc:date>
    </item>
  </channel>
</rss>

