<?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 Group and count values by group? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/349445#M103453</link>
    <description>&lt;P&gt;Thanks a lot Harshil and Gurav for quick response. Both the answers worked for me, although with a bit different results &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
In fact, I found another way too:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;| chart count over Category by Status&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Wed, 31 Jan 2018 10:31:11 GMT</pubDate>
    <dc:creator>rpradeep</dc:creator>
    <dc:date>2018-01-31T10:31:11Z</dc:date>
    <item>
      <title>How to Group and count values by group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/349442#M103450</link>
      <description>&lt;P&gt;I have a table like below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Servername  Category                 Status
Server_1        C_1             Completed
Server_2        C_2             Completed
Server_3        C_2             Completed
Server_4        C_3             Completed
Server_5        C_3             Pending
Server_6        C_3             Completed
Server_7        C_4             Completed
Server_8        C_4             Pending
Server_9        C_4             Pending
Server_10       C_4             Pending
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to get count like below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Category            Status          Count
C_1             Completed            1
                        Pending                  0
C_2             Completed            2
                        Pending                  0
C_3             Completed            2
                        Pending                  1
C_4             Completed            1
                        Pending                  3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can this be done in Splunk? Please help&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 11:11:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/349442#M103450</guid>
      <dc:creator>rpradeep</dc:creator>
      <dc:date>2018-01-30T11:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Group and count values by group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/349443#M103451</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;You can try below query:&lt;BR /&gt;
    | stats count(eval(Status=="Completed")) AS Completed count(eval(Status=="Pending")) AS Pending by Category&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 13:41:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/349443#M103451</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-01-30T13:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Group and count values by group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/349444#M103452</link>
      <description>&lt;P&gt;Hi @rpradeep,&lt;/P&gt;

&lt;P&gt;You can try below run anywhere search (first ten lines are used to generated dummy data only)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval Servername="Server_1", Category="C_1", Status="Completed"
| append [ makeresults | eval Servername="Server_2", Category="C_2", Status="Completed"  ]
| append [ makeresults | eval Servername="Server_3", Category="C_2", Status="Completed"  ]
| append [ makeresults | eval Servername="Server_4", Category="C_3", Status="Completed"  ]
| append [ makeresults | eval Servername="Server_5", Category="C_3", Status="Pending"    ]
| append [ makeresults | eval Servername="Server_6", Category="C_3", Status="Completed"  ]
| append [ makeresults | eval Servername="Server_7", Category="C_4", Status="Completed"  ]
| append [ makeresults | eval Servername="Server_8", Category="C_4", Status="Pending"    ]
| append [ makeresults | eval Servername="Server_9", Category="C_4", Status="Pending"    ]
| append [ makeresults | eval Servername="Server_10", Category="C_4", Status="Pending"   ]
| stats count by Category,Status
| stats values(Status) AS Status, values(count) AS Count by Category
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So based on this your query will be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| stats count by Category,Status
| stats values(Status) AS Status, values(count) AS Count by Category
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Harshil&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 13:43:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/349444#M103452</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-01-30T13:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to Group and count values by group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/349445#M103453</link>
      <description>&lt;P&gt;Thanks a lot Harshil and Gurav for quick response. Both the answers worked for me, although with a bit different results &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
In fact, I found another way too:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;| chart count over Category by Status&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 31 Jan 2018 10:31:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/349445#M103453</guid>
      <dc:creator>rpradeep</dc:creator>
      <dc:date>2018-01-31T10:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to Group and count values by group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/621398#M215985</link>
      <description>&lt;P&gt;| makeresults | eval _raw="Servername,Category,Status&lt;BR /&gt;Server_1,C_1,Completed&lt;BR /&gt;Server_2,C_2,Completed&lt;BR /&gt;Server_3,C_2,Completed&lt;BR /&gt;Server_4,C_3,Completed&lt;BR /&gt;Server_5,C_3,Pending&lt;BR /&gt;Server_6,C_3,Completed&lt;BR /&gt;Server_7,C_4,Completed&lt;BR /&gt;Server_8,C_4,Pending&lt;BR /&gt;Server_9,C_4,Pending&lt;BR /&gt;Server_10,C_4,Pending"&lt;BR /&gt;| multikv forceheader=1&lt;BR /&gt;| stats count by Category,Status&lt;BR /&gt;| stats values(Status) AS Status, values(count) AS Count by Category&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 16:46:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Group-and-count-values-by-group/m-p/621398#M215985</guid>
      <dc:creator>elkhalloufi</dc:creator>
      <dc:date>2022-11-18T16:46:26Z</dc:date>
    </item>
  </channel>
</rss>

