<?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 get a stats sum of a column available in every row? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129358#M35171</link>
    <description>&lt;P&gt;The command name makes this unintuitive, but you can use eventstats to add this to every row...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats count(eval(dead=1)) as sumOfDead
| eventstats count(eval(dead=0)) as sumOfAlive
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 20 Jul 2015 15:43:12 GMT</pubDate>
    <dc:creator>mrobichaud_splu</dc:creator>
    <dc:date>2015-07-20T15:43:12Z</dc:date>
    <item>
      <title>How to get a stats sum of a column available in every row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129357#M35170</link>
      <description>&lt;P&gt;I am creating a simple stats search. I am trying to work out that chance that a part will die over time. I consider a part dead if it has not sent me a status message in the last 20 minutes. This is what I have so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Base search
| bucket _time span=1d
| stats latest(_time) AS LatestTime, earliest(_time) AS EarliestTime by PartID
| eval delayDays=(NOW()-LatestTime)/60/60/24
| eval dead=if((delayDays&amp;gt;20),1,0)
| eval lifeLength=(LatestTime - EarliestTime)/60/60/24
| chart count(eval(dead=0)) as "numberAlive", count(eval(dead=1)) as "numberDead" by lifeLength span=1
| eval sumOfDeadAlive=numberAlive+numberDead
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The last piece of the puzzle for me is to create an eval that pretty much does the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval SurvivalRate = (Sum(sumOfDeadAlive) - (numberDead)) / (Sum(sumOfDeadAlive))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is I cannot work out how to get the sum of the sumOfDeadAlive column without destroying the chart currently as is.&lt;BR /&gt;
If the total number of the sumOfDeadAlive is 150 I want to have access to that 150 in every row.&lt;/P&gt;

&lt;P&gt;I hope this makes sense.&lt;/P&gt;

&lt;P&gt;Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2015 07:25:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129357#M35170</guid>
      <dc:creator>Amohlmann</dc:creator>
      <dc:date>2015-07-20T07:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a stats sum of a column available in every row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129358#M35171</link>
      <description>&lt;P&gt;The command name makes this unintuitive, but you can use eventstats to add this to every row...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats count(eval(dead=1)) as sumOfDead
| eventstats count(eval(dead=0)) as sumOfAlive
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jul 2015 15:43:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129358#M35171</guid>
      <dc:creator>mrobichaud_splu</dc:creator>
      <dc:date>2015-07-20T15:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a stats sum of a column available in every row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129359#M35172</link>
      <description>&lt;P&gt;If you're current Output is this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;lifeLength          numberAlive              numberDead             sumOfDeadAlive
1                             60                                90                                   150
2                             40                                 50                                   90
.......
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What is your expected output?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2015 15:55:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129359#M35172</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-07-20T15:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a stats sum of a column available in every row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129360#M35173</link>
      <description>&lt;P&gt;Sorry I should have been a bit clearer. The main thing I cannot get is the sum of the sumOfDeadAlive column. So in your example I want another column or at least access to the number 240 (150 + 90). &lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2015 22:02:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129360#M35173</guid>
      <dc:creator>Amohlmann</dc:creator>
      <dc:date>2015-07-20T22:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a stats sum of a column available in every row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129361#M35174</link>
      <description>&lt;P&gt;Ahh. Thanks your answer set me off in the right direction. I was trying to mess with streamstats instead of eventstats.&lt;/P&gt;

&lt;P&gt;My Answer was to just slap in a |eventstats sum(sumOfDeadAlive)&lt;/P&gt;

&lt;P&gt;That gives me everything I need super easily.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2015 22:09:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129361#M35174</guid>
      <dc:creator>Amohlmann</dc:creator>
      <dc:date>2015-07-20T22:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a stats sum of a column available in every row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129362#M35175</link>
      <description>&lt;P&gt;It will not let me post another question for some reason.&lt;BR /&gt;
Do you know how to get the product of a streamstats instead of the sum?&lt;/P&gt;

&lt;P&gt;I have a query that returns the survival rate over time. For instance:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Time                SurvivalRate     
1                        0.98                    
2                        0.96                     
3                        0.65
4                        1
.                          .
.                          .
.                          .
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to show a running survival rate that is like streamstats sum(survivalRate) but instead of adding the numbers in each new line, it multiplies it. So it would return something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Time                SurvivalRate     RunningSurvivalRate
1                        0.98                    0.98
2                        0.96                    0.9408 (0.98 * 0.96)
3                        0.65                    0.61152 (0.9408 * 0.65)
4                        1                       0.61125 (0.61152 * 1)
.                          .
.                          .
.                          .
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Am I using the wrong tool for this job? Is there a streamstats function that I am ignorant of?&lt;BR /&gt;
Thanks for the assistance.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2015 03:16:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-a-stats-sum-of-a-column-available-in-every-row/m-p/129362#M35175</guid>
      <dc:creator>Amohlmann</dc:creator>
      <dc:date>2015-07-21T03:16:48Z</dc:date>
    </item>
  </channel>
</rss>

