<?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: How do I get ratio of counts from one search to counts from another? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52092#M12647</link>
    <description>&lt;P&gt;oh right. then you need:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=eventtracking | stats count, values(user_guid) as UserList by eventtype,treatment | eventstats dc(UserList) as UserCount by treatment | eval pct=100*count/UserCount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Mar 2013 17:10:18 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2013-03-06T17:10:18Z</dc:date>
    <item>
      <title>How do I get ratio of counts from one search to counts from another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52087#M12642</link>
      <description>&lt;P&gt;I'm using splunk to track events that happen with users in different treatments of a split test.  For example, how often do users in treatment 1 register or perform a search vs. users in treatment 2 or treatment 3.&lt;/P&gt;

&lt;P&gt;I can see the results to see the raw number of times each event occurred for each treatment using something like the following:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;sourcetype=eventtracking | stats count by eventtype, treatment&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Which produces something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Search  treatment1  900
Search  treatment2  200
Login   treatment1  135
Login   treatment2  10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works great when all the tests are equal - if there are 2 treatments at 50% each for example.  But when the tests are unequal, for example if one treatment is at 10% and the other at 90%, it's hard to find meaning in the graphs, because the larger group will always have more events.&lt;/P&gt;

&lt;P&gt;I can get a count of how many users are in each group using something like the following:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;sourcetype=eventtracking | stats distinct_count(user_guid) as count by treatment&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Which produces something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;treatment1  90
treatment2  10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd like to see the number of times an event occurred divided by the number of people in the test group, to even out the playing field.  I've tried a number of different things with no luck.  How can I combine these queries to see proportional results, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Search  treatment1  10
Search  treatment2  20
Login   treatment1  1.5
Login   treatment2  1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:26:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52087#M12642</guid>
      <dc:creator>mariagullickson</dc:creator>
      <dc:date>2020-09-28T13:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get ratio of counts from one search to counts from another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52088#M12643</link>
      <description>&lt;P&gt;If you do an individual search for each treatment group and eventtype, i.e:&lt;/P&gt;

&lt;P&gt;sourcetype=eventtracking eventype=search treatment=treatment1&lt;/P&gt;

&lt;P&gt;then you could just do an eval on the two results:&lt;/P&gt;

&lt;P&gt;sourcetype=eventtracking eventype=search treatment=treatment1 | stats distinct_count(user_guid) as Users | eval percentage=(Users/count)*100&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:26:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52088#M12643</guid>
      <dc:creator>amars1983</dc:creator>
      <dc:date>2020-09-28T13:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get ratio of counts from one search to counts from another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52089#M12644</link>
      <description>&lt;P&gt;Thanks!  I have been trying to figure this out for a couple of weeks, and of course just came up with the right answer shortly after posting.  This version works across treatments without me having to hardcode the treatment names:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;sourcetype=eventtracking | stats count as EventCount by treatment, eventtype  | join treatment [search sourcetype=eventtracking | stats distinct_count(user_guid) as UserCount by treatment] | eval ratio = EventCount / UserCount&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:26:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52089#M12644</guid>
      <dc:creator>mariagullickson</dc:creator>
      <dc:date>2020-09-28T13:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get ratio of counts from one search to counts from another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52090#M12645</link>
      <description>&lt;P&gt;The most efficient way is to use &lt;CODE&gt;eventstats&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=eventtracking
| stats count
        dc(user_guid) as UserCount
  by eventtype, treatment
| eventstats sum(UserCount) as UserCount by treatment
| eval pct=100*count/UserCount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Mar 2013 23:35:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52090#M12645</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2013-03-05T23:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get ratio of counts from one search to counts from another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52091#M12646</link>
      <description>&lt;P&gt;Thanks for the suggestion.  The problem there is that the distinct count is no longer distinct.  A user will get counted once per eventtype, not once overall.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2013 14:19:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52091#M12646</guid>
      <dc:creator>mariagullickson</dc:creator>
      <dc:date>2013-03-06T14:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get ratio of counts from one search to counts from another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52092#M12647</link>
      <description>&lt;P&gt;oh right. then you need:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=eventtracking | stats count, values(user_guid) as UserList by eventtype,treatment | eventstats dc(UserList) as UserCount by treatment | eval pct=100*count/UserCount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Mar 2013 17:10:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52092#M12647</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2013-03-06T17:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get ratio of counts from one search to counts from another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52093#M12648</link>
      <description>&lt;P&gt;Sorry it's taken me a week to reply.  But that's perfect.  Gets exactly what I want.  Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2013 12:59:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-ratio-of-counts-from-one-search-to-counts-from/m-p/52093#M12648</guid>
      <dc:creator>mariagullickson</dc:creator>
      <dc:date>2013-03-13T12:59:21Z</dc:date>
    </item>
  </channel>
</rss>

