<?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 to divide 2 distinct counts of aggregated values using eval? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-divide-2-distinct-counts-of-aggregated-values-using-eval/m-p/140801#M38954</link>
    <description>&lt;P&gt;Can you provide sample data and sample results? Not sure what exactly you are looking for.&lt;/P&gt;

&lt;P&gt;In terms of your dc(group1) / dc(group2), it doesn't work that way, because group1 and group2 are values of the field "action". Distinct count of action [dc(action)], would return only 1 for group1, 1 for group2, and 1 for any other action value you have in the action field.&lt;/P&gt;

&lt;P&gt;Are you trying to count the number of results that are action=group1 and the results that are action=group2? For this you can just pipe into "stats count by action", or simply add count after your "dc(id)" to also get the count by action.&lt;/P&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
    <pubDate>Mon, 01 Dec 2014 14:58:46 GMT</pubDate>
    <dc:creator>aholzer</dc:creator>
    <dc:date>2014-12-01T14:58:46Z</dc:date>
    <item>
      <title>How to divide 2 distinct counts of aggregated values using eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-divide-2-distinct-counts-of-aggregated-values-using-eval/m-p/140800#M38953</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm new to splunk and not able to figure out the solution to the problem below.&lt;BR /&gt;
Query: |eval action=if(field1="value1", "group1", if(field2="value2", "group2", action))| stats dc(id) by action&lt;/P&gt;

&lt;P&gt;From the above query, I get the count for values aggregated under group1 and group2. I would also want a field which calculates value for dc("group1") divided upon by dc("group2"). &lt;/P&gt;

&lt;P&gt;Please let me know how to get it.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2014 12:22:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-divide-2-distinct-counts-of-aggregated-values-using-eval/m-p/140800#M38953</guid>
      <dc:creator>fayazvf</dc:creator>
      <dc:date>2014-12-01T12:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to divide 2 distinct counts of aggregated values using eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-divide-2-distinct-counts-of-aggregated-values-using-eval/m-p/140801#M38954</link>
      <description>&lt;P&gt;Can you provide sample data and sample results? Not sure what exactly you are looking for.&lt;/P&gt;

&lt;P&gt;In terms of your dc(group1) / dc(group2), it doesn't work that way, because group1 and group2 are values of the field "action". Distinct count of action [dc(action)], would return only 1 for group1, 1 for group2, and 1 for any other action value you have in the action field.&lt;/P&gt;

&lt;P&gt;Are you trying to count the number of results that are action=group1 and the results that are action=group2? For this you can just pipe into "stats count by action", or simply add count after your "dc(id)" to also get the count by action.&lt;/P&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2014 14:58:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-divide-2-distinct-counts-of-aggregated-values-using-eval/m-p/140801#M38954</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2014-12-01T14:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to divide 2 distinct counts of aggregated values using eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-divide-2-distinct-counts-of-aggregated-values-using-eval/m-p/140802#M38955</link>
      <description>&lt;P&gt;hi,&lt;BR /&gt;
I think that this will have to help you. &lt;BR /&gt;
You should initially count all the values of Group1 and Group2, then to make a division.&lt;BR /&gt;
&lt;STRONG&gt;grou1:&lt;/STRONG&gt;&lt;CODE&gt;|eval action=if(field1="value1", "group1", if(field2="value2", "group2", action))| where action="goup1"| stats c by action as GROUP1&lt;/CODE&gt;&lt;BR /&gt;
&lt;STRONG&gt;group2:&lt;/STRONG&gt;&lt;CODE&gt;|eval action=if(field1="value1", "group1", if(field2="value2", "group2", action))| where action="goup2"| stats c by action as GROUP2&lt;/CODE&gt;&lt;BR /&gt;
&lt;STRONG&gt;division&lt;/STRONG&gt;&lt;CODE&gt;eval Division=GROUP1/GROUP2]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;General solution:&lt;/STRONG&gt;&lt;CODE&gt;|eval action=if(field1="value1", "group1", if(field2="value2", "group2", action))| where action="goup1"| stats c by action as GROUP1|appencolds [search  ...|eval action=if(field1="value1", "group1", if(field2="value2", "group2", action))| where action="goup2"|stats c by action as GROUP2]| eval Division=GROUP1/GROUP2&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Dec 2014 09:44:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-divide-2-distinct-counts-of-aggregated-values-using-eval/m-p/140802#M38955</guid>
      <dc:creator>Tanefo</dc:creator>
      <dc:date>2014-12-17T09:44:06Z</dc:date>
    </item>
  </channel>
</rss>

