<?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 avg of time values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750879#M242438</link>
    <description>&lt;P&gt;Thank you. Giving your karma points&lt;/P&gt;</description>
    <pubDate>Fri, 01 Aug 2025 05:32:15 GMT</pubDate>
    <dc:creator>neerajs_81</dc:creator>
    <dc:date>2025-08-01T05:32:15Z</dc:date>
    <item>
      <title>Calculate avg of time values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750794#M242416</link>
      <description>&lt;P&gt;Hello All,&amp;nbsp; Below is my dataset from a base query. How can i calculate the average value of the column ?&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="12.5%" height="25px"&gt;Incident&lt;/TD&gt;&lt;TD width="12.5%" height="25px"&gt;avg_time&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;days&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;hrs&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="47px"&gt;P1&lt;/TD&gt;&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;1 hour, 29 minutes&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;SPAN&gt;0.06181041204508532&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;SPAN&gt;1.4834498890820478&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;SPAN&gt;29.00699334492286&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="47px"&gt;P2&lt;/TD&gt;&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;1 hour, 18 minutes&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;0.05428940107829018&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&amp;nbsp;&lt;SPAN&gt;1.3029456258789642&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;SPAN&gt;18.176737552737862&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;I need to display the average of the avg_time values. Since there is date/time involved, merely doing the below function is not working&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;stats avg(avg_time) as average_ttc_overall&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 08:39:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750794#M242416</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2025-07-31T08:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate avg of time values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750796#M242417</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229059"&gt;@neerajs_81&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When it's formatted as strings like "1 hour, 29 minutes", you'll need to convert those time strings into a numeric format first(typically total minutes) before applying stats avg()&lt;/P&gt;&lt;P&gt;Eg:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| your_base_search
| eval time_parts=split(avg_time, ", ")
| eval hours=tonumber(replace(mvindex(time_parts, 0), " hour[s]?", ""))
| eval minutes=tonumber(replace(mvindex(time_parts, 1), " minute[s]?", ""))
| eval total_minutes=(hours * 60) + minutes
| stats avg(total_minutes) as average_min&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 09:02:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750796#M242417</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-07-31T09:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate avg of time values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750798#M242419</link>
      <description>&lt;P&gt;It looks like all these times are based on a common (other unshown) field. Perhaps it would be helpful it you shared more information about how these current fields are calculated as there may be a different calculation you can do to get you nearer to your desired result?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 09:27:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750798#M242419</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-07-31T09:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate avg of time values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750806#M242422</link>
      <description>&lt;P&gt;Thanks a lot. I got the average_min as per your query but now how do i convert / represent it back to hours minutes format ?&lt;/P&gt;&lt;PRE&gt;| stats avg(total_minutes) as average_min&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; For example your query gave me the average_min= 112.9&amp;nbsp; . How do i convert this back to show as 1 hour, 8 minutes&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 12:51:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750806#M242422</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2025-07-31T12:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate avg of time values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750807#M242423</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval average_min=tostring(average_min,"duration")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 31 Jul 2025 12:58:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750807#M242423</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-07-31T12:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate avg of time values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750810#M242424</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; &amp;nbsp;Tried that as i found the same on your other posts. But this is what is displays the result as .&amp;nbsp; How to make it&amp;nbsp; show as 1h, 45 mins ?&amp;nbsp; More easily readable format in days, hours ,minutes.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neerajs_81_0-1753967157540.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39798i60C332EF14FE93A9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="neerajs_81_0-1753967157540.png" alt="neerajs_81_0-1753967157540.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 13:07:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750810#M242424</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2025-07-31T13:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate avg of time values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750813#M242425</link>
      <description>&lt;P&gt;1. As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;noticed - you might be reinventing the wheel since probably the value comes from some earlier time-based data so there could be no need for rendering and parsing this value back and forth&lt;/P&gt;&lt;P&gt;2. Are you sure (you might be, just asking) that you want to calculate average of the averages? If the overall average is what you're seeking, an average of averages will not give you that.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 13:29:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750813#M242425</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-07-31T13:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate avg of time values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750818#M242427</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=field_in_hhmmss "((?&amp;lt;days&amp;gt;\d+)\+)?((?&amp;lt;hours&amp;gt;\d+):)?((?&amp;lt;minutes&amp;gt;\d+):)?(?&amp;lt;seconds&amp;gt;[\d\.]+)"
| eval formatted=if(days &amp;gt; 0,days." days, ","").if(days &amp;gt; 0 OR hours &amp;gt; 0,hours." hours, ","").if(days &amp;gt; 0 OR hours &amp;gt; 0 OR minutes &amp;gt; 0,minutes." mins, ","").if(seconds &amp;gt; 0,seconds." secs","")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 31 Jul 2025 14:09:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750818#M242427</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-07-31T14:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate avg of time values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750864#M242435</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229059"&gt;@neerajs_81&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use below for avg_mins and avg_hours.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval time_parts=split(avg_time, ", ")
| eval hours=tonumber(replace(mvindex(time_parts, 0), " hour[s]?", ""))
| eval minutes=tonumber(replace(mvindex(time_parts, 1), " minute[s]?", ""))
| eval total_minutes=(hours * 60) + minutes
| stats avg(total_minutes) as average_ttc_overall
| eval avg_hours=floor(average_ttc_overall / 60)
| eval avg_minutes=round(average_ttc_overall % 60)
| eval hour_avg=avg_hours . " hr " . avg_minutes . " mins" | table average_ttc_overall hour_avg&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Aug 2025 04:10:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750864#M242435</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-08-01T04:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate avg of time values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750879#M242438</link>
      <description>&lt;P&gt;Thank you. Giving your karma points&lt;/P&gt;</description>
      <pubDate>Fri, 01 Aug 2025 05:32:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-avg-of-time-values/m-p/750879#M242438</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2025-08-01T05:32:15Z</dc:date>
    </item>
  </channel>
</rss>

