<?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: Compare count of unique values over two different time periods in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Compare-count-of-unique-values-over-two-different-time-periods/m-p/207613#M187767</link>
    <description>&lt;P&gt;Lots of ways to do this. One method is just using eval (you may need to adjust this based on your field names eg department)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yoursearch&amp;gt; earliest =-90d@d | eval UniqueUsersNinetyDays =if(_time&amp;lt;relative_time(now(),"-30d"),user,NULL) |eval UniqueUsersThirtyDays=if(_time&amp;gt;relative_time(now(),"-30d"),user,NULL)|   stats dc(UniqueUsersNinetyDays) as UniqueUsersNinetyDays dc(UniqueUsersThirtyDays) as UniqueUsersThirtyDays by department| eval Ratio=UniqueUsersNinetyDays/UniqueUsersThirtyDays
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could also run a couple of subsearches, or use eventstats. As a newbie, I highly recommend you get familiar with stats, chart and eval. The documentation for these commands is great. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Chart"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Chart&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Eval"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Eval&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Also search for those commands on splunk answers - there are lots of real world examples&lt;/P&gt;</description>
    <pubDate>Wed, 23 Dec 2015 18:42:54 GMT</pubDate>
    <dc:creator>jplumsdaine22</dc:creator>
    <dc:date>2015-12-23T18:42:54Z</dc:date>
    <item>
      <title>Compare count of unique values over two different time periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-count-of-unique-values-over-two-different-time-periods/m-p/207612#M187766</link>
      <description>&lt;P&gt;Please forgive my ignorance, I am newbie to Splunk.  I am trying to depict a unique count of users over two different time periods and show a ratio between the two. I would like to the following: A=Active users that have logged on within the last 90 days by department, B= Active users that have logged on with the last 30 days by department  C: ratio between A and B by department.  I have figured  how to get A and B as separate queries, but how do I combine them into a single table?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 14:05:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-count-of-unique-values-over-two-different-time-periods/m-p/207612#M187766</guid>
      <dc:creator>kennyja</dc:creator>
      <dc:date>2015-12-23T14:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Compare count of unique values over two different time periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-count-of-unique-values-over-two-different-time-periods/m-p/207613#M187767</link>
      <description>&lt;P&gt;Lots of ways to do this. One method is just using eval (you may need to adjust this based on your field names eg department)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yoursearch&amp;gt; earliest =-90d@d | eval UniqueUsersNinetyDays =if(_time&amp;lt;relative_time(now(),"-30d"),user,NULL) |eval UniqueUsersThirtyDays=if(_time&amp;gt;relative_time(now(),"-30d"),user,NULL)|   stats dc(UniqueUsersNinetyDays) as UniqueUsersNinetyDays dc(UniqueUsersThirtyDays) as UniqueUsersThirtyDays by department| eval Ratio=UniqueUsersNinetyDays/UniqueUsersThirtyDays
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could also run a couple of subsearches, or use eventstats. As a newbie, I highly recommend you get familiar with stats, chart and eval. The documentation for these commands is great. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Chart"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Chart&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Eval"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Eval&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Also search for those commands on splunk answers - there are lots of real world examples&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 18:42:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-count-of-unique-values-over-two-different-time-periods/m-p/207613#M187767</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2015-12-23T18:42:54Z</dc:date>
    </item>
  </channel>
</rss>

