<?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 calculate the average for all values in a single column? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/600561#M209064</link>
    <description>&lt;P&gt;I did found an better way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval value = "1.2 2.5 0.5" | makemv value | mvexpand value
| eval count=1
| addcoltotals
| eval value=if(count&amp;gt;1,value/count,value)
| fields - count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_time	        value
2022-06-04 10:08:55	1.2
2022-06-04 10:08:55	2.5
2022-06-04 10:08:55	0.5
 	                1.4&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 04 Jun 2022 08:30:27 GMT</pubDate>
    <dc:creator>jotne</dc:creator>
    <dc:date>2022-06-04T08:30:27Z</dc:date>
    <item>
      <title>How to calculate the average for all values in a single column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210063#M61435</link>
      <description>&lt;P&gt;This one seems pretty straight forward, but I haven't been able to find an answer anywhere. I'm looking to calculate the average for all the values in a single column, kind of like addcoltotals. Example of what I am trying to achieve:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;User        Time(Hours)
user1       1.2
user2       2.0
user3       0.5
            (average here)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Apr 2016 13:38:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210063#M61435</guid>
      <dc:creator>jpolcari</dc:creator>
      <dc:date>2016-04-20T13:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average for all values in a single column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210064#M61436</link>
      <description>&lt;P&gt;You can do it like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| stats sum(Time) as totalTime by User
| appendpipe [ stats avg(totalTime) as totalTime | eval User = "Average Time" ]
| rename totalTime as "Time (Hours)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;appendpipe&lt;/CODE&gt; commands examines the results in the pipeline, and in this case, calculates an average. The results of the &lt;CODE&gt;appendpipe&lt;/CODE&gt; command are added to the end of the existing results. Notice that I used the same field names within the &lt;CODE&gt;appendpipe&lt;/CODE&gt; command, so that the new results would align in the same columns.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:01:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210064#M61436</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-04-20T14:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average for all values in a single column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210065#M61437</link>
      <description>&lt;P&gt;Thank you! That is exactly what I needed.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:06:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210065#M61437</guid>
      <dc:creator>jpolcari</dc:creator>
      <dc:date>2016-04-20T14:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average for all values in a single column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210066#M61438</link>
      <description>&lt;P&gt;You would think that there would be a "family" of commands similar to addcoltotals, such as addcolaverage...&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:52:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210066#M61438</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2016-04-20T14:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average for all values in a single column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210067#M61439</link>
      <description>&lt;P&gt;That is what I was hoping for. Maybe one day!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:57:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210067#M61439</guid>
      <dc:creator>jpolcari</dc:creator>
      <dc:date>2016-04-20T14:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average for all values in a single column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210068#M61440</link>
      <description>&lt;P&gt;I am trying to do something similar, but this solution is not working to me.&lt;BR /&gt;
avg(totalTime) returns totalTime as it is the average of a single value. So I end up with a table for total times by user instead of the average by user. &lt;BR /&gt;
I had to add the total number of occurrences and at the end divide the total value for the number of occurrences per user.&lt;/P&gt;

&lt;P&gt;rgds,&lt;BR /&gt;
Juan&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 20:13:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/210068#M61440</guid>
      <dc:creator>jperezes</dc:creator>
      <dc:date>2017-02-10T20:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average for all values in a single column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/600561#M209064</link>
      <description>&lt;P&gt;I did found an better way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval value = "1.2 2.5 0.5" | makemv value | mvexpand value
| eval count=1
| addcoltotals
| eval value=if(count&amp;gt;1,value/count,value)
| fields - count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_time	        value
2022-06-04 10:08:55	1.2
2022-06-04 10:08:55	2.5
2022-06-04 10:08:55	0.5
 	                1.4&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jun 2022 08:30:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-for-all-values-in-a-single-column/m-p/600561#M209064</guid>
      <dc:creator>jotne</dc:creator>
      <dc:date>2022-06-04T08:30:27Z</dc:date>
    </item>
  </channel>
</rss>

