<?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 search the percentage change between multiple dates? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-percentage-change-between-multiple-dates/m-p/223329#M65743</link>
    <description>&lt;P&gt;Have you looked at appendcols?&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Appendcols"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Appendcols&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Nov 2015 17:03:05 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2015-11-10T17:03:05Z</dc:date>
    <item>
      <title>How to search the percentage change between multiple dates?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-percentage-change-between-multiple-dates/m-p/223328#M65742</link>
      <description>&lt;P&gt;So I loaded some old stock market data into Splunk and now I'm trying to make a big table that shows the percentage change from 1 week ago, 1 month ago etc.&lt;/P&gt;

&lt;P&gt;What I want to end up with is something like this:&lt;BR /&gt;
** symbol    |    1w change | 1m change **&lt;BR /&gt;
   SPY              |      5%      |  10%&lt;BR /&gt;
   SPLK              |     3%       |  15%&lt;/P&gt;

&lt;P&gt;All events have the fields like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Adj Close = 210.039993
Close = 210.039993
Date = 2015-11-06
High = 210.320007
Low = 208.460007
Open = 209.740005
Volume = 105423100
category = Large Blend
index = quote
name = SPDR S&amp;amp;P 500 ETF
sourcetype = his_quote
symbol = SPY 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is it possible to do what I want to? I have not been able to get close to what I want. &lt;/P&gt;

&lt;P&gt;I tried to do something like this (pseudo code), but it is not working for me. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search get all quote data | save latest as close_now
| subsearch [ search earliest=-1w | save latest as close_1w_ago
| eval diff_pct=(close_now-close_1w_ago)/close_1w_ago*100
| table symbol diff_pct as "1w change"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help would be appreciated&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 05:39:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-percentage-change-between-multiple-dates/m-p/223328#M65742</guid>
      <dc:creator>jihape</dc:creator>
      <dc:date>2015-11-10T05:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the percentage change between multiple dates?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-percentage-change-between-multiple-dates/m-p/223329#M65743</link>
      <description>&lt;P&gt;Have you looked at appendcols?&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Appendcols"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Appendcols&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 17:03:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-percentage-change-between-multiple-dates/m-p/223329#M65743</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2015-11-10T17:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the percentage change between multiple dates?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-percentage-change-between-multiple-dates/m-p/223330#M65744</link>
      <description>&lt;P&gt;I figured it out.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=quote earliest=-1w latest=now | stats earliest(Close) as e_close latest(Close) as l_close by symbol | eval 1w=(l_close-e_close)/e_close*100 
| appendcols [ search index=quote earliest=-2w latest=now | stats earliest(Close) as e_close latest(Close) as l_close by symbol | eval 2w=(l_close-e_close)/e_close*100 ] 
| fields symbol 1w 2w
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Nov 2015 03:16:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-percentage-change-between-multiple-dates/m-p/223330#M65744</guid>
      <dc:creator>jihape</dc:creator>
      <dc:date>2015-11-13T03:16:33Z</dc:date>
    </item>
  </channel>
</rss>

