<?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 combine Values Within Stats Command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-Values-Within-Stats-Command/m-p/450928#M127690</link>
    <description>&lt;P&gt;@whunterj try the following eval after your fields pipe &lt;CODE&gt;| eval majorCustomer=case(majorCustomer IN ("commercial","information systems"),"Corporate",true(),majorCustomer)&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=citrix majorCustomer=* Host=*
| fields majorCustomer Host
| eval majorCustomer=case(majorCustomer IN ("commercial","information systems"),"Corporate",true(),majorCustomer)
| rename majorCustomer as "Line of Business"
| stats count(Host) as Servers by "Line of Business"
| eventstats sum(Servers) as Total
| eval Percentage = (Servers/Total)*100
| eval Percentage = round(Percentage, 2)
| eval Percentage = Percentage + "%"
| table "Line of Business" Servers Percentage
| sort -Servers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: &lt;CODE&gt;IN&lt;/CODE&gt; clause will work only if you are on &lt;CODE&gt;Splunk 6.6&lt;/CODE&gt; or higher, or else you would need to use &lt;CODE&gt;majorCustomer=="commercial" OR majorCustomer=="information systems"&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jun 2019 14:07:17 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2019-06-27T14:07:17Z</dc:date>
    <item>
      <title>How to combine Values Within Stats Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-Values-Within-Stats-Command/m-p/450927#M127689</link>
      <description>&lt;P&gt;I have written a search that breaks down the four values in the majorCustomer field and counts the number of servers in each of the four majorCustomers. What I want to do is combine the commercial and information systems customer into one called corporate and have the count be a sum of their individual server counts. Any suggestions?&lt;/P&gt;

&lt;P&gt;This is the search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=citrix
| fields majorCustomer Host
| rename majorCustomer as "Line of Business"
| stats count(Host) as Servers by "Line of Business"
| eventstats sum(Servers) as Total
| eval Percentage = (Servers/Total)*100
| eval Percentage = round(Percentage, 2)
| eval Percentage = Percentage + "%"
| table "Line of Business" Servers Percentage
| sort -Servers!
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.comstorage/temp/273086-query-question.png"&gt;alt text&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 13:35:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-Values-Within-Stats-Command/m-p/450927#M127689</guid>
      <dc:creator>whunterj</dc:creator>
      <dc:date>2019-06-27T13:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Values Within Stats Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-Values-Within-Stats-Command/m-p/450928#M127690</link>
      <description>&lt;P&gt;@whunterj try the following eval after your fields pipe &lt;CODE&gt;| eval majorCustomer=case(majorCustomer IN ("commercial","information systems"),"Corporate",true(),majorCustomer)&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=citrix majorCustomer=* Host=*
| fields majorCustomer Host
| eval majorCustomer=case(majorCustomer IN ("commercial","information systems"),"Corporate",true(),majorCustomer)
| rename majorCustomer as "Line of Business"
| stats count(Host) as Servers by "Line of Business"
| eventstats sum(Servers) as Total
| eval Percentage = (Servers/Total)*100
| eval Percentage = round(Percentage, 2)
| eval Percentage = Percentage + "%"
| table "Line of Business" Servers Percentage
| sort -Servers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: &lt;CODE&gt;IN&lt;/CODE&gt; clause will work only if you are on &lt;CODE&gt;Splunk 6.6&lt;/CODE&gt; or higher, or else you would need to use &lt;CODE&gt;majorCustomer=="commercial" OR majorCustomer=="information systems"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 14:07:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-Values-Within-Stats-Command/m-p/450928#M127690</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-06-27T14:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Values Within Stats Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-Values-Within-Stats-Command/m-p/450929#M127691</link>
      <description>&lt;P&gt;This is exactly what I was trying to do. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 15:19:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-Values-Within-Stats-Command/m-p/450929#M127691</guid>
      <dc:creator>whunterj</dc:creator>
      <dc:date>2019-06-27T15:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Values Within Stats Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-Values-Within-Stats-Command/m-p/450930#M127692</link>
      <description>&lt;P&gt;If that's it, then click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the question.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 16:03:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-Values-Within-Stats-Command/m-p/450930#M127692</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-27T16:03:09Z</dc:date>
    </item>
  </channel>
</rss>

