<?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 How to create a time chart with the percentage difference between two searches over time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398513#M115572</link>
    <description>&lt;P&gt;In the search below I have appended two identical searches that are 1 week apart. &lt;BR /&gt;
I would like to find the difference in percent between the two over time. &lt;BR /&gt;
I am aware of the &lt;CODE&gt;timewrap&lt;/CODE&gt; function but that's not exactly sure how it could help here. &lt;BR /&gt;
A &lt;CODE&gt;timechart&lt;/CODE&gt; of percentage difference would be ideal.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="blah" earliest=-192h latest=-168h | setfields when='1 week ago' | eval _time = _time+604800 | append [search index="blah" earliest=-24h latest=now | setfields when='0 week ago'] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 May 2019 20:16:51 GMT</pubDate>
    <dc:creator>pr0n</dc:creator>
    <dc:date>2019-05-28T20:16:51Z</dc:date>
    <item>
      <title>How to create a time chart with the percentage difference between two searches over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398513#M115572</link>
      <description>&lt;P&gt;In the search below I have appended two identical searches that are 1 week apart. &lt;BR /&gt;
I would like to find the difference in percent between the two over time. &lt;BR /&gt;
I am aware of the &lt;CODE&gt;timewrap&lt;/CODE&gt; function but that's not exactly sure how it could help here. &lt;BR /&gt;
A &lt;CODE&gt;timechart&lt;/CODE&gt; of percentage difference would be ideal.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="blah" earliest=-192h latest=-168h | setfields when='1 week ago' | eval _time = _time+604800 | append [search index="blah" earliest=-24h latest=now | setfields when='0 week ago'] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 May 2019 20:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398513#M115572</guid>
      <dc:creator>pr0n</dc:creator>
      <dc:date>2019-05-28T20:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a time chart with the percentage difference between two searches over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398514#M115573</link>
      <description>&lt;P&gt;@pr0n you can try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;yourCurrentSearch&amp;gt;
| timechart count by when
| eval "diff %"=round((('0 week ago'-'1 week ago')/'0 week ago')*100,2)
| fillnull "diff %" value=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you have &lt;CODE&gt;diff %&lt;/CODE&gt; you can create a chart overlay to plot it on top of your existing output.&lt;/P&gt;

&lt;P&gt;However, at the same time since append will run into sub-search limitation, you can try the &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Multisearch#Subsearch_processing_and_limitations"&gt;multisearch&lt;/A&gt; command instead. Following is a run anywhere search based on Splunk's _internal index.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| multisearch 
    [ search index="_internal" earliest=-192h latest=-168h 
    | setfields when="1 week ago" 
    | eval _time = _time+604800] 
    [ search index="_internal" earliest=-24h latest=now 
    | setfields when="0 week ago"] 
| timechart count by when 
| eval "diff %"=round((('0 week ago'-'1 week ago')/'0 week ago')*100,2) 
| fillnull "diff %" value=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2019 03:27:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398514#M115573</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-05-29T03:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a time chart with the percentage difference between two searches over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398515#M115574</link>
      <description>&lt;P&gt;"diff %" ends up being null (and thus 0)  when I attempt your top method. After experimenting it seems that '0 week ago' and '1 week ago' don't reference anything.  Unfortunately I don't have the ability to query our _internal index but I think I can structure this to keep it under 10k. &lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 15:58:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398515#M115574</guid>
      <dc:creator>pr0n</dc:creator>
      <dc:date>2019-05-29T15:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a time chart with the percentage difference between two searches over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398516#M115575</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index="blah" earliest=-169h latest=-168h | timechart count AS count_1weekago | appendcols
[search index="blah" earliest=-1h latest=now | timechart count AS count_now]
| eval DiffPercent = (count_now - count_1weekago) / count_1weekago * 100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is what worked.&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 17:10:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398516#M115575</guid>
      <dc:creator>pr0n</dc:creator>
      <dc:date>2019-05-29T17:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a time chart with the percentage difference between two searches over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398517#M115576</link>
      <description>&lt;P&gt;@pr0n if you have null values for current week and/or previous week, you can get null for diff% and hence 0, which is expected. Do accept the answer if you found this helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 17:51:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398517#M115576</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-05-29T17:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a time chart with the percentage difference between two searches over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398518#M115577</link>
      <description>&lt;P&gt;Null is not expected, there are definitely values there. I have made an answer post which was my solution.&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 17:58:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-with-the-percentage-difference/m-p/398518#M115577</guid>
      <dc:creator>pr0n</dc:creator>
      <dc:date>2019-05-29T17:58:29Z</dc:date>
    </item>
  </channel>
</rss>

