<?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: Group data, but keeping data to be grouped. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383333#M111949</link>
    <description>&lt;P&gt;Thank you for the tip...&lt;/P&gt;</description>
    <pubDate>Fri, 29 Mar 2019 10:44:00 GMT</pubDate>
    <dc:creator>dreadangel</dc:creator>
    <dc:date>2019-03-29T10:44:00Z</dc:date>
    <item>
      <title>Group data, but keeping data to be grouped.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383330#M111946</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I got some data structured next: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;url    user     event
-------------------------------------
Url1, user1, EventType1
Url1, user1, EventType2
Url2, user1, EventType3
Url2, user1, EventType1
Url1, user2, EventType1
Url2, user2, EventType2
Url3, user2, EventType3
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My goal is to build a statistics table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    [Url],  [Total events count], [Distinct users count], [Top $x users + count list]
    Url1                       2                       2                     user1 - 1
                                                                             user2 - 1
    -----------------------------------------------------------------------------------
    Url2,                      3,                      1,                    user1 - 1
                                                                             user2 - 1
    -----------------------------------------------------------------------------------
    Url3,                      1,                      1,                    user2 - 1
    -----------------------------------------------------------------------------------
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After using &lt;STRONG&gt;stats&lt;/STRONG&gt; command in pipeline grouped data isn't available anymore, so is it possible "to add" statistics to the result or should I use multiple subsearches - each acquiting its goal and after joining them?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 14:03:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383330#M111946</guid>
      <dc:creator>dreadangel</dc:creator>
      <dc:date>2019-03-28T14:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Group data, but keeping data to be grouped.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383331#M111947</link>
      <description>&lt;P&gt;@dreadangel ,&lt;/P&gt;

&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"base search"|stats dc(event) as "Event Count" , dc(user) as Distinct_Users, values(user) as Users by Url
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you need further stats by keeping this data , use &lt;CODE&gt;eventstats&lt;/CODE&gt; . For eg. &lt;CODE&gt;|eventstats count as "Total_URL_Count"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 14:53:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383331#M111947</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-03-28T14:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Group data, but keeping data to be grouped.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383332#M111948</link>
      <description>&lt;P&gt;It might be a bit ugly, but this query gives exactly the result you want...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your_base_query&amp;gt; | stats count as "Total Events", dc(user) as "Distinct Users" by url | appendcols [&amp;lt;your_base_query&amp;gt; | stats count by url, user | eval user = user." - ".count | stats list(user) as "Users + count" by url]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In case you want a distinct event count an no total count, just swap the first &lt;CODE&gt;stats count&lt;/CODE&gt; for a &lt;CODE&gt;stats dc(events)&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:12:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383332#M111948</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-03-28T15:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Group data, but keeping data to be grouped.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383333#M111949</link>
      <description>&lt;P&gt;Thank you for the tip...&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 10:44:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383333#M111949</guid>
      <dc:creator>dreadangel</dc:creator>
      <dc:date>2019-03-29T10:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Group data, but keeping data to be grouped.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383334#M111950</link>
      <description>&lt;P&gt;Thank you for the tip upon eventstats - this indeed solves &lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 10:44:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-data-but-keeping-data-to-be-grouped/m-p/383334#M111950</guid>
      <dc:creator>dreadangel</dc:creator>
      <dc:date>2019-03-29T10:44:47Z</dc:date>
    </item>
  </channel>
</rss>

