<?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: Calculate total count difference per day in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489034#M136607</link>
    <description>&lt;P&gt;cool @Sfry1981&lt;/P&gt;

&lt;P&gt;Glad to help you&lt;/P&gt;</description>
    <pubDate>Wed, 29 Apr 2020 15:24:12 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2020-04-29T15:24:12Z</dc:date>
    <item>
      <title>Calculate total count difference per day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489031#M136604</link>
      <description>&lt;P&gt;I have a set of data like the below&lt;/P&gt;

&lt;P&gt;total=2000&lt;BR /&gt;
date=2020-04-29&lt;/P&gt;

&lt;P&gt;total=1975&lt;BR /&gt;
date=2020-04-28&lt;/P&gt;

&lt;P&gt;total=1951&lt;BR /&gt;
date=2020-04-27&lt;/P&gt;

&lt;P&gt;What I want to produce is a chart that shows the difference per day of these totals i.e as per the below&lt;/P&gt;

&lt;P&gt;total difference = 25&lt;BR /&gt;
date=2020-04-29&lt;/P&gt;

&lt;P&gt;total difference=24&lt;BR /&gt;
date=2020-04-28&lt;/P&gt;

&lt;P&gt;total=33&lt;BR /&gt;
date=2020-04-27&lt;/P&gt;

&lt;P&gt;etc&lt;/P&gt;

&lt;P&gt;I need a calculation of the difference per day&lt;/P&gt;

&lt;P&gt;my raw data already has the total and date in so its a straight calculation from that data&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 14:50:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489031#M136604</guid>
      <dc:creator>Sfry1981</dc:creator>
      <dc:date>2020-04-29T14:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate total count difference per day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489032#M136605</link>
      <description>&lt;P&gt;@Sfry1981 &lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | eval t=strptime(date,"%Y-%m-%d") | sort t | streamstats window=2 first(total) as p | eval diff=total-p | table date total diff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Sample Search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval  total=2000, date="2020-04-29"
| append [ | makeresults | eval total=1975,date="2020-04-28"]
| append [ | makeresults | eval total=1951, date="2020-04-27"] | eval t=strptime(date,"%Y-%m-%d") | sort t | streamstats window=2 first(total) as p | eval diff=total-p | table date total diff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Just change search as per your  requirement.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 15:00:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489032#M136605</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-04-29T15:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate total count difference per day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489033#M136606</link>
      <description>&lt;P&gt;@kamlesh_vaghela &lt;/P&gt;

&lt;P&gt;As the date was in a string format i removed "eval t=strptime(date,"%Y-%m-%d")" and then it worked. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 15:11:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489033#M136606</guid>
      <dc:creator>Sfry1981</dc:creator>
      <dc:date>2020-04-29T15:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate total count difference per day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489034#M136607</link>
      <description>&lt;P&gt;cool @Sfry1981&lt;/P&gt;

&lt;P&gt;Glad to help you&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 15:24:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489034#M136607</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-04-29T15:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate total count difference per day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489035#M136608</link>
      <description>&lt;P&gt;@kamlesh_vaghela i have 1 issue. It shows all the previous figures as minus so it inverts the graphs but i want them to show as positives. I tried "| eval mynum=abs(mynum)" but this doesnt work. Do you know how to amend? &lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 15:34:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489035#M136608</guid>
      <dc:creator>Sfry1981</dc:creator>
      <dc:date>2020-04-29T15:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate total count difference per day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489036#M136609</link>
      <description>&lt;P&gt;@Sfry1981&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eval mynum=abs(mynum)&lt;/CODE&gt; should work. &lt;/P&gt;

&lt;P&gt;Try:&lt;BR /&gt;
&lt;CODE&gt;|makeresults count=10 | eval a=-1 | accum a |eval mynum=a | eval mynum=abs(mynum)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Can you please share your sample search and sample value you getting in &lt;CODE&gt;mynum&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 04:54:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489036#M136609</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-04-30T04:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate total count difference per day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489037#M136610</link>
      <description>&lt;P&gt;sorry @kamlesh_vaghela It was my mistake, where i was charting i was using the incorrect value. School boy error. All working again. Thanks for all your help. &lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 07:20:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-count-difference-per-day/m-p/489037#M136610</guid>
      <dc:creator>Sfry1981</dc:creator>
      <dc:date>2020-04-30T07:20:23Z</dc:date>
    </item>
  </channel>
</rss>

