<?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 create a table result with &amp;quot;stats count by ‘field’&amp;quot;? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281453#M84914</link>
    <description>&lt;P&gt;Instead of stats use chart&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;accountName=* results=* | chart count over result by accountName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You might have to reverse the order and by fields as I often flip those mentally =). The only real gottcha to chart (or timechart for that matter) is if you use any commands after the chart command fields like count don't exist anymore as they would with stats. In your case after the chart command the fields you would have would be accountName, Pass, Failed, Error, Delayed. I mention that only because you will have to take that into account if you want to do things like sort the results.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2015 12:36:23 GMT</pubDate>
    <dc:creator>Runals</dc:creator>
    <dc:date>2015-12-17T12:36:23Z</dc:date>
    <item>
      <title>How do I create a table result with "stats count by ‘field’"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281450#M84911</link>
      <description>&lt;P&gt;I have a set of events which have multiple values for a single field such as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;accountName=customerA result=[passed|failed|error|delayed]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can obtain the  statistical result of these results using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;stats count by result, accountName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which gives me up to 4 rows per customer with the count of relevant events. However, I would like to tabulate this data to make it more readable:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|           | Pass | Failed | Error | Delayed |
| CustomerA | 100  | 10     | 12    | 10      |
| CustomerB | 200  | 5      |       | 20      |
| CustomerC | 50   | 6      | 3     | 30      |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a simple method to achieve this? I am sure i must be missing something obvious.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 08:26:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281450#M84911</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2015-12-17T08:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a table result with "stats count by ‘field’"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281451#M84912</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
Could you try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex "\|(?&amp;lt;customer&amp;gt;[^\|]+\|(?&amp;lt;pass&amp;gt;[^\|]+\|(?&amp;lt;failed&amp;gt;[^\|]+\|(?&amp;lt;error&amp;gt;[^\|]+\|(?&amp;lt;delayed&amp;gt;[^\|]+"
|stats values(pass) as pass values(failed) as failed values(error) as error values(delayed) as delayed by customer
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Dec 2015 08:55:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281451#M84912</guid>
      <dc:creator>jmallorquin</dc:creator>
      <dc:date>2015-12-17T08:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a table result with "stats count by ‘field’"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281452#M84913</link>
      <description>&lt;P&gt;so far, I am using:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;|eval Pass=if(result="pass",1,0) |eval Failed=if(result="failed",1,0)|eval Error=if(result="error",1,0)|stats count as Total sum(Pass) as Pass sum(Failed) as Failed sum(Error) as Error by customer&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Which gives the desired output, but I can't help but think there could be an easier way.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 10:43:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281452#M84913</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2015-12-17T10:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a table result with "stats count by ‘field’"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281453#M84914</link>
      <description>&lt;P&gt;Instead of stats use chart&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;accountName=* results=* | chart count over result by accountName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You might have to reverse the order and by fields as I often flip those mentally =). The only real gottcha to chart (or timechart for that matter) is if you use any commands after the chart command fields like count don't exist anymore as they would with stats. In your case after the chart command the fields you would have would be accountName, Pass, Failed, Error, Delayed. I mention that only because you will have to take that into account if you want to do things like sort the results.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 12:36:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281453#M84914</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2015-12-17T12:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a table result with "stats count by ‘field’"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281454#M84915</link>
      <description>&lt;P&gt;I think you might want to use xyseries as your final command where you write:&lt;BR /&gt;
xyseries accountName,result,count&lt;/P&gt;

&lt;P&gt;So you'd have something like:&lt;BR /&gt;
yourInitialSearch | stats count by result, accountName | xyseries accountName,result,count&lt;/P&gt;</description>
      <pubDate>Sun, 19 Feb 2017 16:09:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-result-with-quot-stats-count-by-field/m-p/281454#M84915</guid>
      <dc:creator>mkhiani_splunk</dc:creator>
      <dc:date>2017-02-19T16:09:08Z</dc:date>
    </item>
  </channel>
</rss>

