<?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: Grouping and Counting the Group Values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139150#M38219</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count values(user) dc(user) by country
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 05 Feb 2014 20:12:29 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-02-05T20:12:29Z</dc:date>
    <item>
      <title>Grouping and Counting the Group Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139149#M38218</link>
      <description>&lt;P&gt;Hello.&lt;BR /&gt;
I have a requirement of presenting a table with Countries, users and the number of users in that country..&lt;BR /&gt;
SO I have a query :&lt;BR /&gt;
…{query}..| stats count values(user)  by country &lt;/P&gt;

&lt;P&gt;This will give me :&lt;/P&gt;

&lt;P&gt;something like :&lt;/P&gt;

&lt;P&gt;country       User&lt;/P&gt;

&lt;P&gt;USA-------u1&lt;/P&gt;

&lt;P&gt;-------------u2&lt;/P&gt;

&lt;P&gt;-------------u3&lt;/P&gt;

&lt;P&gt;-------------u4&lt;/P&gt;

&lt;P&gt;UK -------u5&lt;/P&gt;

&lt;P&gt;-------------u6&lt;/P&gt;

&lt;P&gt;What do I do to the query , so that it gives me the count of the number of users in the third column: something like :&lt;/P&gt;

&lt;P&gt;country       User   UserCount &lt;/P&gt;

&lt;P&gt;USA-------u1------ 4&lt;/P&gt;

&lt;P&gt;-------------u2&lt;/P&gt;

&lt;P&gt;-------------u3&lt;/P&gt;

&lt;P&gt;-------------u4&lt;/P&gt;

&lt;P&gt;UK -------u5----------2&lt;/P&gt;

&lt;P&gt;-------------u6&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 20:10:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139149#M38218</guid>
      <dc:creator>kanda18</dc:creator>
      <dc:date>2014-02-05T20:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping and Counting the Group Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139150#M38219</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count values(user) dc(user) by country
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Feb 2014 20:12:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139150#M38219</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-02-05T20:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping and Counting the Group Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139151#M38220</link>
      <description>&lt;P&gt;Thank you sir..&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 20:29:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139151#M38220</guid>
      <dc:creator>kanda18</dc:creator>
      <dc:date>2014-02-05T20:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping and Counting the Group Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139152#M38221</link>
      <description>&lt;P&gt;Hey,&lt;BR /&gt;
This works great on the splunk interface, but when I generate a report to be sent to an email, with the inline results, the users  show on single line. In the splunk search, the table is neat, with the users on a new line. Is there a way to make sure that the splunk result shows in email as is ? with the new lines etc?I tried to do eval userNames=mvjoin(UsersMV,"#") .I think i need to do something to replace the # from the userNames and add a new line \n in regex?  not sure. I am surprised that the results in the Splunk interface is different from the results in the email&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 23:17:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139152#M38221</guid>
      <dc:creator>kanda18</dc:creator>
      <dc:date>2014-02-05T23:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping and Counting the Group Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139153#M38222</link>
      <description>&lt;P&gt;Rendering in the UI and in an inline table of an email is inherently different. Off the top of my head you could try two things: You could &lt;CODE&gt;mvexpand&lt;/CODE&gt; the values(user) field, giving you one copied event per user along with the counts... or you could indeed try to mvjoin() the users with a \n newline character... if that doesn't work, try joining them with an HTML &amp;lt;br&amp;gt; tag, provided Splunk isn't smart and replaces that with ampersand-entities.&lt;/P&gt;

&lt;P&gt;If all that fails, you could create your own version of the sendemail.py script and build the inline tables as you need them.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 23:27:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-and-Counting-the-Group-Values/m-p/139153#M38222</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-02-05T23:27:14Z</dc:date>
    </item>
  </channel>
</rss>

