<?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: Daily and weekly discrete count in the same query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Daily-and-weekly-discrete-count-in-the-same-query/m-p/580067#M202122</link>
    <description>&lt;P&gt;The key here is use eventstats to calculate the distinct count over the entire week range and retain that value "max(dc_weekly)" through subsequent stats -- first stats calculate distinct daily and second stat to calculate average daily.&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jan 2022 00:52:57 GMT</pubDate>
    <dc:creator>johnhuang</dc:creator>
    <dc:date>2022-01-06T00:52:57Z</dc:date>
    <item>
      <title>Daily and weekly discrete count in the same query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Daily-and-weekly-discrete-count-in-the-same-query/m-p/580059#M202117</link>
      <description>&lt;P&gt;I've got some queries I need to do periodically that use the exact same base search, one with teh weekly uniques and one with the average daily uniques. I can do these seperately:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;(search)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;| stats dc(thing) as WeeklyCount&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;(search)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;|bucket _time span=day&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;|stats dc(thing) as DailyCount by _time&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;|stats avg(DailyCount)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried variations on appendpipe, but can't get it to work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;(search)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;| stats dc(thing) as WeeklyCount&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;|appendpipe [&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;bucket _time span=day&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;|stats dc(thing) as DailyCount by _time&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;|stats avg(DailyCount)]&lt;/P&gt;&lt;P&gt;returns only WeeklyCount. If I switch the order and have weeklycount in the append pipe, it gives my the correct average daily, but weekly reports as 0&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 22:59:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Daily-and-weekly-discrete-count-in-the-same-query/m-p/580059#M202117</guid>
      <dc:creator>dantose</dc:creator>
      <dc:date>2022-01-05T22:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Daily and weekly discrete count in the same query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Daily-and-weekly-discrete-count-in-the-same-query/m-p/580061#M202118</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;.....
| eventstats dc(thing) AS dc_weekly
| bucket _time span=1d
| stats min(_time) AS start_time max(_time) AS end_time dc(thing) AS dc_daily max(dc_weekly) AS dc_weekly BY _time
| stats min(_time) AS start_time max(_time) AS end_time avg(dc_daily) AS dc_daily max(dc_weekly) AS dc_weekly
| eval start_date=strftime(start_time, "%m-%d-%Y"), end_date=strftime(end_time, "%m-%d-%Y")
| eval dc_daily=ROUND(dc_daily)
| table start_date end_date dc_daily dc_weekly&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 05 Jan 2022 23:29:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Daily-and-weekly-discrete-count-in-the-same-query/m-p/580061#M202118</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-01-05T23:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Daily and weekly discrete count in the same query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Daily-and-weekly-discrete-count-in-the-same-query/m-p/580065#M202121</link>
      <description>&lt;P&gt;That did it! Would you mind explaining it a bit?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 00:41:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Daily-and-weekly-discrete-count-in-the-same-query/m-p/580065#M202121</guid>
      <dc:creator>dantose</dc:creator>
      <dc:date>2022-01-06T00:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Daily and weekly discrete count in the same query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Daily-and-weekly-discrete-count-in-the-same-query/m-p/580067#M202122</link>
      <description>&lt;P&gt;The key here is use eventstats to calculate the distinct count over the entire week range and retain that value "max(dc_weekly)" through subsequent stats -- first stats calculate distinct daily and second stat to calculate average daily.&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 00:52:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Daily-and-weekly-discrete-count-in-the-same-query/m-p/580067#M202122</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-01-06T00:52:57Z</dc:date>
    </item>
  </channel>
</rss>

