<?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 average based on 2 fields and group the result by values in the third field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510969#M143111</link>
    <description>&lt;P&gt;the same solution would work using indexed data. you just have to apply the same concept. He's proved out his point by creating sandbox data basedon your initial question. BTW, i would say his response is the best solution. I wouldn't recommend over complicating it.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 25 Jul 2020 17:54:42 GMT</pubDate>
    <dc:creator>spammenot66</dc:creator>
    <dc:date>2020-07-25T17:54:42Z</dc:date>
    <item>
      <title>How to calculate average based on 2 fields and group the result by values in the third field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510953#M143107</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This is the first time, I've used Splunk. &amp;nbsp;I have the data like this:&lt;/P&gt;&lt;TABLE border="1" width="56.2493567142533%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="24px"&gt;&lt;STRONG&gt;ORDER_ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;&lt;STRONG&gt;PRICE&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;&lt;STRONG&gt;GROUP&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="24px"&gt;00001&lt;/TD&gt;&lt;TD height="24px"&gt;10&lt;/TD&gt;&lt;TD height="24px"&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="24px"&gt;00002&lt;/TD&gt;&lt;TD height="24px"&gt;20&lt;/TD&gt;&lt;TD height="24px"&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="24px"&gt;00003&lt;/TD&gt;&lt;TD height="24px"&gt;20&lt;/TD&gt;&lt;TD height="24px"&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px"&gt;00004&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;15&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px"&gt;00005&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;23.3&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want to calculate the average price for each group, which returns the result like this:&lt;/P&gt;&lt;TABLE border="1" width="44.44329996869568%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;&lt;STRONG&gt;GROUP&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;&lt;STRONG&gt;AVERAGE_PRICE&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;A&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;B&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;17.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;C&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;23.3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order to do this average calculation, I know that I have to calculate the total number of ORDER_ID and the sum of PRICE for each GROUP. But I don't know how to perform this calculation in SPL. Please kindly guild me through this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regard.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jul 2020 16:14:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510953#M143107</guid>
      <dc:creator>dominhthe110</dc:creator>
      <dc:date>2020-07-25T16:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate average based on 2 fields and group the result by values in the third field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510955#M143108</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;LI-CODE lang="java"&gt;| makeresults
| eval _raw="ORDER_ID, PRICE, GROUP
00001,10,A
00002,20,B
00003,20,A
00004,15,B
00005,23.3,C"
| multikv forceheader=1
| stats avg(PRICE) AS AVERAGE_PRICE by GROUP&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 25 Jul 2020 16:24:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510955#M143108</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-07-25T16:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate average based on 2 fields and group the result by values in the third field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510962#M143110</link>
      <description>&lt;P&gt;Thank you a lot. It worked.&lt;BR /&gt;But I just wonder is there any other ways that I can calculate it step by step not using the avg() function?&amp;nbsp;&lt;BR /&gt;Assump that the data is indexed so that we don't need the "eval _raw="..." line.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jul 2020 17:18:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510962#M143110</guid>
      <dc:creator>dominhthe110</dc:creator>
      <dc:date>2020-07-25T17:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate average based on 2 fields and group the result by values in the third field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510969#M143111</link>
      <description>&lt;P&gt;the same solution would work using indexed data. you just have to apply the same concept. He's proved out his point by creating sandbox data basedon your initial question. BTW, i would say his response is the best solution. I wouldn't recommend over complicating it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jul 2020 17:54:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510969#M143111</guid>
      <dc:creator>spammenot66</dc:creator>
      <dc:date>2020-07-25T17:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate average based on 2 fields and group the result by values in the third field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510972#M143112</link>
      <description>&lt;P&gt;Yes it works without first lines (like &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/97643"&gt;@spammenot66&lt;/a&gt;&amp;nbsp;@said), which only create data to do actual calculation (last line). Just use it with your indexed data.&amp;nbsp;&lt;BR /&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jul 2020 18:17:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-average-based-on-2-fields-and-group-the-result/m-p/510972#M143112</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-07-25T18:17:59Z</dc:date>
    </item>
  </channel>
</rss>

