<?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: Calculate percentage in every row | adding two search results into one in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316494#M163607</link>
    <description>&lt;P&gt;Did the same. Thanks for the help.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jan 2018 15:04:02 GMT</pubDate>
    <dc:creator>shiv1593</dc:creator>
    <dc:date>2018-01-16T15:04:02Z</dc:date>
    <item>
      <title>Calculate percentage in every row | adding two search results into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316486#M163599</link>
      <description>&lt;P&gt;I am fairly new to Splunk and I have a Two fold question. I am running a query to find the top issues reported in the last three months. Below is my query:&lt;/P&gt;

&lt;P&gt;host="service_desk_tickets" Region=AMER "Sub Category"=* extracted_Source=* Created="&lt;EM&gt;" Summary="&lt;/EM&gt;" Number="*"&lt;BR /&gt;
     | stats count(Number) AS "Number Of Tickets" BY extracted_Source Summary&lt;BR /&gt;
     | chart sum("Number Of Tickets") OVER Summary BY extracted_Source&lt;BR /&gt;
     | rename Summary AS "Top Issues Reported By Clients"&lt;BR /&gt;
     | addtotals&lt;BR /&gt;
     | sort - Total&lt;BR /&gt;
     | addcoltotals labelfield="Top Issues Reported By Clients"&lt;/P&gt;

&lt;P&gt;Here is the resultant of it:&lt;/P&gt;

&lt;P&gt;.&lt;IMG src="https://community.splunk.com/storage/temp/226734-query.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;My Questions are:&lt;/P&gt;

&lt;P&gt;1&amp;gt; How can I add another Column called Percentage and calculate the average percentage of the total in terms of the total number of events. Example: Row 1 has a total of 1024, so 1024 is 13.646% of 7504 (My total number of events)&lt;/P&gt;

&lt;P&gt;2&amp;gt; Can I change something in my query to add combine Row 5 and Row 7 into one row, Row 1, 2, 4, into one row, naming it as a new row and add their totals into one, as they are pretty much the same issue, password reset or account unlock. If possible. I have heard that once indexed, data fields can't be added into one.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:43:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316486#M163599</guid>
      <dc:creator>shiv1593</dc:creator>
      <dc:date>2020-09-29T17:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage in every row | adding two search results into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316487#M163600</link>
      <description>&lt;P&gt;can you put your code in &lt;CODE&gt;101010&lt;/CODE&gt; format?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 11:09:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316487#M163600</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-16T11:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage in every row | adding two search results into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316488#M163601</link>
      <description>&lt;P&gt;okay to solve your first query&lt;/P&gt;

&lt;P&gt;you can try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="service_desk_tickets" Region=AMER "Sub Category"= extracted_Source= Created="" Summary="" Number="*"
| stats count(Number) AS "Number Of Tickets" BY extracted_Source Summary
| chart sum("Number Of Tickets") OVER Summary BY extracted_Source
| rename Summary AS "Top Issues Reported By Clients"
| addtotals
| sort - Total
| eventstats sum(Total) as Total1
| eval pecentage=Total1*100/Total
| addcoltotals labelfield="Top Issues Reported By Clients" | fields - Total1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now for your second query, in order to combine multiple count you can use &lt;CODE&gt;replace&lt;/CODE&gt; command. let suppose you want to combine &lt;CODE&gt;AD Password reset&lt;/CODE&gt; and  &lt;CODE&gt;AD accound unlock&lt;/CODE&gt; into a value called &lt;CODE&gt;Reset&lt;/CODE&gt;....you can replace multiple values like that..I am just showing you how to do with two values..you can do the same for multiple values like that&lt;/P&gt;

&lt;P&gt;then you can change your query as &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host="service_desk_tickets" Region=AMER "Sub Category"= extracted_Source= Created="" Summary="" Number="*"
| replace "AD Password reset" WITH "Reset" "AD accound reset" WITH "Reset" IN Summary 
| stats count(Number) AS "Number Of Tickets" BY extracted_Source Summary
 | chart sum("Number Of Tickets") OVER Summary BY extracted_Source
 | rename Summary AS "Top Issues Reported By Clients"
 | addtotals
 | sort - Total
 | eventstats sum(Total) as Total1
 | eval pecentage=Total1*100/Total
 | addcoltotals labelfield="Top Issues Reported By Clients" | fields - Total1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 11:16:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316488#M163601</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-16T11:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage in every row | adding two search results into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316489#M163602</link>
      <description>&lt;P&gt;use &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.1/SearchReference/Streamstats"&gt;streamstats&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 11:43:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316489#M163602</guid>
      <dc:creator>paramagurukarth</dc:creator>
      <dc:date>2018-01-16T11:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage in every row | adding two search results into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316490#M163603</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;host="service_desk_tickets" Region=AMER "Sub Category"= extracted_Source= Created="" Summary="" Number="*"
| stats count(Number) AS "Number Of Tickets" BY extracted_Source Summary
| chart sum("Number Of Tickets") OVER Summary BY extracted_Source
| rename Summary AS "Top Issues Reported By Clients"
| addtotals
| sort - Total
| addcoltotals labelfield="Top Issues Reported By Clients"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jan 2018 11:46:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316490#M163603</guid>
      <dc:creator>shiv1593</dc:creator>
      <dc:date>2018-01-16T11:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage in every row | adding two search results into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316491#M163604</link>
      <description>&lt;P&gt;I have updated my query check my solution and let me know if it helps!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 11:51:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316491#M163604</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-16T11:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage in every row | adding two search results into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316492#M163605</link>
      <description>&lt;P&gt;Thanks a lot Mayur. Your solution works perfectly, with a change. The correct Percentage will be calculated by eval pecentage=Total*100/Total1. Apart from that, it is perfect.&lt;/P&gt;

&lt;P&gt;Replace command is working wonders  too, but I have a lot of fields to combine, which might make the query way too long. Is there an alternative, where I can use specific keywords and combine the data, like by using Password reset, or Account unlock and combine whichever field have these keywords?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 12:47:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316492#M163605</guid>
      <dc:creator>shiv1593</dc:creator>
      <dc:date>2018-01-16T12:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage in every row | adding two search results into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316493#M163606</link>
      <description>&lt;P&gt;you can use wildcard operator &lt;CODE&gt;*&lt;/CODE&gt; . like | &lt;CODE&gt;replace *reset* WITH Reset IN Summary&lt;/CODE&gt;&lt;BR /&gt;
let me know if this helps !&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 12:54:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316493#M163606</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-16T12:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage in every row | adding two search results into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316494#M163607</link>
      <description>&lt;P&gt;Did the same. Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 15:04:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-in-every-row-adding-two-search-results-into/m-p/316494#M163607</guid>
      <dc:creator>shiv1593</dc:creator>
      <dc:date>2018-01-16T15:04:02Z</dc:date>
    </item>
  </channel>
</rss>

