<?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 Average of stats two fields values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502438#M195191</link>
    <description>&lt;P&gt;I have Below Splunk query to get some data from my logs&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype "search string" 
| stats sum(TotalRecords) As "Total Records", sum(TotalTime_Taken) As "Total Time Taken" by Content
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Below is the result of the above query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Content_Type            Total Records         Total Time Taken
==========              =============          ===========
Documents                   13                     25
Blogs                       25                    120
Events                      2                       5  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want another column in my result &lt;STRONG&gt;Average_time_taken&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Average_time_taken&lt;/STRONG&gt; = Total Time Taken / Total Records &lt;/P&gt;

&lt;P&gt;The result should be as below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Content_Type            Total Records         Total Time Taken                Average_time_taken
    ==========              =============          ===========               ====================
    Documents                   13                     25                          1.9230
    Blogs                       25                    120                          4.8
    Events                      2                       5                          2.5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 30 Sep 2020 05:30:12 GMT</pubDate>
    <dc:creator>paragvidhi</dc:creator>
    <dc:date>2020-09-30T05:30:12Z</dc:date>
    <item>
      <title>Average of stats two fields values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502438#M195191</link>
      <description>&lt;P&gt;I have Below Splunk query to get some data from my logs&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype "search string" 
| stats sum(TotalRecords) As "Total Records", sum(TotalTime_Taken) As "Total Time Taken" by Content
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Below is the result of the above query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Content_Type            Total Records         Total Time Taken
==========              =============          ===========
Documents                   13                     25
Blogs                       25                    120
Events                      2                       5  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want another column in my result &lt;STRONG&gt;Average_time_taken&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Average_time_taken&lt;/STRONG&gt; = Total Time Taken / Total Records &lt;/P&gt;

&lt;P&gt;The result should be as below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Content_Type            Total Records         Total Time Taken                Average_time_taken
    ==========              =============          ===========               ====================
    Documents                   13                     25                          1.9230
    Blogs                       25                    120                          4.8
    Events                      2                       5                          2.5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:30:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502438#M195191</guid>
      <dc:creator>paragvidhi</dc:creator>
      <dc:date>2020-09-30T05:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Average of stats two fields values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502439#M195192</link>
      <description>&lt;P&gt;You can just do an eval to create the new field. The only trick is that the field names within the eval statement will need to be in either single quotes or dollar signs to indicate to Splunk that you're referencing fields&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Average_time_taken='Total Time Taken'/'Total Records'
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 May 2020 17:04:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502439#M195192</guid>
      <dc:creator>acfecondo75</dc:creator>
      <dc:date>2020-05-18T17:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Average of stats two fields values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502440#M195193</link>
      <description>&lt;P&gt;it doesn't work for me, I need to use data that I got from stats result, and based on that result I need Average_time_taken.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:30:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502440#M195193</guid>
      <dc:creator>paragvidhi</dc:creator>
      <dc:date>2020-09-30T05:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Average of stats two fields values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502441#M195194</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype "search string" 
| stats sum(TotalRecords) As T, sum(TotalTime_Taken) As TT by Content
| eval Average_time_taken= TT / T
| rename T as "Total Records" , TT as "Total Time Taken", Content as Content_Type
| table  Content_Type "Total Records" "Total Time Taken" Average_time_taken
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Have you try @acfecondo75 recommend like this?&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 14:07:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502441#M195194</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-05-19T14:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: Average of stats two fields values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502442#M195195</link>
      <description>&lt;P&gt;I'm sorry I should have been more clear. Add the eval statement I provided to the search you used that generated the results.&lt;/P&gt;

&lt;P&gt;Given that your results have the fields 'Total Time Taken' and 'Total Records',  it will work.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 04:23:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-of-stats-two-fields-values/m-p/502442#M195195</guid>
      <dc:creator>acfecondo75</dc:creator>
      <dc:date>2020-05-20T04:23:45Z</dc:date>
    </item>
  </channel>
</rss>

