<?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 How to search the average of a distinct count by date_hour over the course of a quarter? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-of-a-distinct-count-by-date-hour-over/m-p/231717#M68727</link>
    <description>&lt;P&gt;I'm looking to get some summary statistics by date_hour on the number of distinct users in our systems.&lt;/P&gt;

&lt;P&gt;Given a data set that looks like:&lt;/P&gt;

&lt;P&gt;OCCURRED_DATE=10/1/2016 12:01:01; USERNAME=Person1&lt;BR /&gt;
OCCURRED_DATE=10/1/2016 12:02:01; USERNAME=Person1&lt;BR /&gt;
OCCURRED_DATE=10/1/2016 12:02:05; USERNAME=Person2&lt;BR /&gt;
OCCURRED_DATE=10/2/2016 12:01:01; USERNAME=Person1&lt;BR /&gt;
OCCURRED_DATE=10/2/2016 12:02:01; USERNAME=Person1&lt;/P&gt;

&lt;P&gt;I know that the dc(USERNAME) for the 12:00 date_hour for 10/1/2016 is 2 and that the dc(USERNAME) for the 12:00 date_hour for 10/2/2016 is 1. I'd like to be able to have Splunk give me the average of those days worth of date_hours (i.e. 1.5)&lt;/P&gt;

&lt;P&gt;I've tried several different iterations of the below without any success.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=usage | timechart span=1h dc(USERNAME) as user_count | stats avg(user_count) by date_hour | sort date_hour
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My original attempt included the below, which also doesn't produce results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=usage | stats avg(dc(USERNAME)) by date_hour | sort date_hour
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 11:17:20 GMT</pubDate>
    <dc:creator>dfenko</dc:creator>
    <dc:date>2020-09-29T11:17:20Z</dc:date>
    <item>
      <title>How to search the average of a distinct count by date_hour over the course of a quarter?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-of-a-distinct-count-by-date-hour-over/m-p/231717#M68727</link>
      <description>&lt;P&gt;I'm looking to get some summary statistics by date_hour on the number of distinct users in our systems.&lt;/P&gt;

&lt;P&gt;Given a data set that looks like:&lt;/P&gt;

&lt;P&gt;OCCURRED_DATE=10/1/2016 12:01:01; USERNAME=Person1&lt;BR /&gt;
OCCURRED_DATE=10/1/2016 12:02:01; USERNAME=Person1&lt;BR /&gt;
OCCURRED_DATE=10/1/2016 12:02:05; USERNAME=Person2&lt;BR /&gt;
OCCURRED_DATE=10/2/2016 12:01:01; USERNAME=Person1&lt;BR /&gt;
OCCURRED_DATE=10/2/2016 12:02:01; USERNAME=Person1&lt;/P&gt;

&lt;P&gt;I know that the dc(USERNAME) for the 12:00 date_hour for 10/1/2016 is 2 and that the dc(USERNAME) for the 12:00 date_hour for 10/2/2016 is 1. I'd like to be able to have Splunk give me the average of those days worth of date_hours (i.e. 1.5)&lt;/P&gt;

&lt;P&gt;I've tried several different iterations of the below without any success.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=usage | timechart span=1h dc(USERNAME) as user_count | stats avg(user_count) by date_hour | sort date_hour
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My original attempt included the below, which also doesn't produce results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=usage | stats avg(dc(USERNAME)) by date_hour | sort date_hour
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:17:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-of-a-distinct-count-by-date-hour-over/m-p/231717#M68727</guid>
      <dc:creator>dfenko</dc:creator>
      <dc:date>2020-09-29T11:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the average of a distinct count by date_hour over the course of a quarter?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-of-a-distinct-count-by-date-hour-over/m-p/231718#M68728</link>
      <description>&lt;P&gt;Timechart is losing the builtin special date fields. If you really want to average it across the same hour for all days, you could use eval's strftime() to re-calculate the hour:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=usage | timechart span=1h dc(USERNAME) as dc | eval hour=strftime(_time, "%H") | stats avg(dc) by hour
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Oct 2016 16:16:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-of-a-distinct-count-by-date-hour-over/m-p/231718#M68728</guid>
      <dc:creator>madhack</dc:creator>
      <dc:date>2016-10-05T16:16:34Z</dc:date>
    </item>
  </channel>
</rss>

