<?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 the average in the total row in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-in-the-total-row/m-p/624805#M217202</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/251844"&gt;@Manasa_401&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The table showed average calculation. Thank you a lot!&lt;/P&gt;</description>
    <pubDate>Tue, 20 Dec 2022 08:07:58 GMT</pubDate>
    <dc:creator>boxmetal</dc:creator>
    <dc:date>2022-12-20T08:07:58Z</dc:date>
    <item>
      <title>How to calculate the average in the total row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-in-the-total-row/m-p/624792#M217197</link>
      <description>&lt;P&gt;Hi Splunk community,&lt;/P&gt;
&lt;P&gt;I need to display data shown as table below&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;Component&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;Total units&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;Violated units&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;Matched [%]&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;Type A&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;99&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;Type B&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;10&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;10&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;75&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;Type C&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;100&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;85&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;85&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;Total&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;111&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;96&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;&lt;FONT color="#FF0000"&gt;86&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the total row, the matched value is the average of the column, while others are the sum value.&lt;/P&gt;
&lt;P&gt;Is it possible to insert the average value to the total row as shown?&lt;/P&gt;
&lt;P&gt;Here's my SPL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index="my_index"source="*sourcename*"
| stats count as total_units count(eval(isnull(approval_message))) as violated_units values(matched_percentage) as matched by component 
| addcoltotals total_units + violated_units labelfield=component
| rename total_units as "Total Units", violated_units as "Violated Units", matched as "Matched [%]"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 14:07:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-in-the-total-row/m-p/624792#M217197</guid>
      <dc:creator>boxmetal</dc:creator>
      <dc:date>2022-12-20T14:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the average in the total row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-in-the-total-row/m-p/624796#M217199</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/246827"&gt;@boxmetal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try the below query:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="my_index"source="*sourcename*"
| stats count as total_units count(eval(isnull(approval_message))) as violated_units values(matched_percentage) as matched by component 
| addcoltotals total_units + violated_units labelfield=component
| streamstats avg(matched) as average
| eval matched=coalesce(matched,average)
| fields - average
| rename total_units as "Total Units", violated_units as "Violated Units", matched as "Matched [%]"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;If this helps an upvote would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Manasa&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 07:40:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-in-the-total-row/m-p/624796#M217199</guid>
      <dc:creator>Manasa_401</dc:creator>
      <dc:date>2022-12-20T07:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the average in the total row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-in-the-total-row/m-p/624805#M217202</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/251844"&gt;@Manasa_401&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The table showed average calculation. Thank you a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 08:07:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-in-the-total-row/m-p/624805#M217202</guid>
      <dc:creator>boxmetal</dc:creator>
      <dc:date>2022-12-20T08:07:58Z</dc:date>
    </item>
  </channel>
</rss>

