<?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: get the chart of count and percentage by, in one column in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/610264#M212220</link>
    <description>&lt;P&gt;Instead of your existing foreach block, replace it with this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach 2* 3* 4* 5* 
    [ eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=if('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'=total OR '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'=0, "", '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'."(".round(100*'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/total)."%)") ]&lt;/LI-CODE&gt;&lt;P&gt;that will only show a value if the field value is not equal to total or 0.&lt;/P&gt;&lt;P&gt;Add the fields - total to remove the total field at the end&lt;/P&gt;</description>
    <pubDate>Mon, 22 Aug 2022 01:36:05 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2022-08-22T01:36:05Z</dc:date>
    <item>
      <title>How to get the chart of count and percentage by- in one column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609547#M211942</link>
      <description>&lt;P class=""&gt;So i am representing endpoint url (y-axis) and http status code (x-axis).&lt;/P&gt;
&lt;P class=""&gt;I can show the count of each url &amp;amp; status code using chart like so:&lt;/P&gt;
&lt;P class=""&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;lt;base search&amp;gt;&amp;nbsp;| chart count by url_path, http_status_code&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class=""&gt;Now, i need to add another item into the chart command to show the percentage of each count in addition to count, so that i get something like&amp;nbsp; this together: 48 (72%).&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;Also i know how to calculate the percentage as such:&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;&lt;EM&gt;eventstats sum(count) as total | eval percent=100*count/total | strcat percent "%" percent.&lt;/EM&gt;&lt;/P&gt;
&lt;P class=""&gt;Can you please tell me how to construct the chart command to encapsulate the count and percentage together?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 00:00:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609547#M211942</guid>
      <dc:creator>djoobbani</dc:creator>
      <dc:date>2022-08-16T00:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: get the chart of count and percentage by, in one column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609551#M211944</link>
      <description>&lt;P&gt;Assuming you mean that percentage is the percentage of status codes per url_path, then this would construct the data,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search...
| addtotals fieldname=total
| foreach 2* 3* 4* 5* [ eval "percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=100*'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/total, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'." (".'percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'."%)" ]
| fields - percent_* total&lt;/LI-CODE&gt;&lt;P&gt;but the problem is that the count is no longer a number, therefore will not chart as a number.&lt;/P&gt;&lt;P&gt;With this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| addtotals fieldname=total
| foreach 2* 3* 4* 5* [ eval "percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=100*'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/total ]
| fields - total&lt;/LI-CODE&gt;&lt;P&gt;you would end up with percent_XXX fields that you could overlay onto a second Y axis, but that's not particularly pretty...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 23:53:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609551#M211944</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-08-15T23:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: get the chart of count and percentage by, in one column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609558#M211946</link>
      <description>&lt;P&gt;Thanks but i need to use &lt;EM&gt;&lt;STRONG&gt;chart&lt;/STRONG&gt;&lt;/EM&gt; command to show both count and percentage by the url (y column) and status code e.g. &lt;EM&gt;&lt;STRONG&gt;54 (81%)&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;The above only shows the log information&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 01:43:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609558#M211946</guid>
      <dc:creator>djoobbani</dc:creator>
      <dc:date>2022-08-16T01:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: get the chart of count and percentage by, in one column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609561#M211949</link>
      <description>&lt;P&gt;You are already using the chart command in your search...&amp;nbsp; What do you mean by only showing log information? I suggested this option&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search...
| addtotals fieldname=total
| foreach 2* 3* 4* 5* [ eval "percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=100*'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/total, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'." (".'percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'."%)" ]
| fields - percent_* total&lt;/LI-CODE&gt;&lt;P&gt;where the text "your_search" is your original search where you are using the chart command...&lt;/P&gt;&lt;P&gt;However, the fundamental issue still applies. You cannot show a number AND a percentage as a Y axis value, as as soon as you combine 54 and (81%) the combination is no longer a number, i.e. "54 (81%)" is not a numeric value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 04:02:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609561#M211949</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-08-16T04:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: get the chart of count and percentage by, in one column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609671#M211995</link>
      <description>&lt;P&gt;Hi bowesmana:&lt;/P&gt;&lt;P&gt;So i got this search working for me:&lt;/P&gt;&lt;P&gt;&amp;lt;my search&amp;gt; | chart count by path_template, http_status_code | addtotals fieldname=total&lt;BR /&gt;| foreach 2* 3* 4* 5* [ eval "percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=round(100*'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/total), "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'." (".'percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'."%)" ]&lt;BR /&gt;| fields - percent_* total&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-08-16 at 8.54.46 AM.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21046i7DF20B84BCF66D9D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-08-16 at 8.54.46 AM.png" alt="Screen Shot 2022-08-16 at 8.54.46 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As u can see the last column doesn't show the total number (both the title and the numbers) based on the above search. Do you know what is wrong? Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 15:57:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609671#M211995</guid>
      <dc:creator>djoobbani</dc:creator>
      <dc:date>2022-08-16T15:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: get the chart of count and percentage by, in one column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609672#M211996</link>
      <description>&lt;P&gt;This may be related to the issue u mentioned about&amp;nbsp;&lt;SPAN&gt;count turning into a non numeric value, correct?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there any other way to calculate the total (both vertically and horizontally)?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 16:04:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609672#M211996</guid>
      <dc:creator>djoobbani</dc:creator>
      <dc:date>2022-08-16T16:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: get the chart of count and percentage by, in one column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609696#M212002</link>
      <description>&lt;P&gt;bwosemana's formula depends on the existence of a field named total, which according to your original description would be derived from&amp;nbsp;&lt;EM&gt;eventstats sum(count) as total&lt;/EM&gt;.&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;&amp;lt;my search&amp;gt; | chart count by path_template, http_status_code | addtotals fieldname=total&lt;BR /&gt;| foreach 2* 3* 4* 5* [ eval "percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=round(100*'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/total), "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'." (".'percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'."%)" ]&lt;BR /&gt;| fields - percent_* total&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;In this code, any information carried by &lt;FONT face="andale mono,times"&gt;total&lt;/FONT&gt;&amp;nbsp;would have been lost in chart. &amp;nbsp;I haven't examined the full logic in this search but if you change to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;my search&amp;gt; | chart count AS total by path_template, http_status_code | addtotals fieldname=total
| foreach 2* 3* 4* 5* [ eval "percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=round(100*'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/total), "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'." (".'percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'."%)" ]
| fields - percent_* total&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you should get some results. (Although I suspect that the results may not be what you expected.)&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 19:22:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609696#M212002</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-08-16T19:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: get the chart of count and percentage by, in one column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609732#M212013</link>
      <description>&lt;P&gt;You are removing the total field in the final line&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fields - percent_* total&lt;/LI-CODE&gt;&lt;P&gt;if you want to retain 'total' then remove total from the above line.&lt;/P&gt;&lt;P&gt;Note that the VALUE column is probably coming from your data somewhere and is some odd value of your http_status_code field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 01:22:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/609732#M212013</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-08-17T01:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: get the chart of count and percentage by, in one column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/610016#M212123</link>
      <description>&lt;P&gt;Thanks for your help bowesmana. Actually i finally got the everything working with the following SPL:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;lt;basic search&amp;gt;&amp;nbsp;| chart count by path_template, http_status_code | addtotals fieldname=total&lt;BR /&gt;| foreach 2* 3* 4* 5* [ eval "percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=round(100*'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/total), "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'." (".'percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'."%)" ] | fields - percent_*&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-08-18 at 11.10.52 AM.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21091iD7EDBDDC6986168F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-08-18 at 11.10.52 AM.png" alt="Screen Shot 2022-08-18 at 11.10.52 AM.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Now, i need to make two changes to this query.&lt;/P&gt;&lt;P&gt;1- Do NOT show the total column&lt;/P&gt;&lt;P&gt;2- For cases where the percentage is either 0 OR 100 do not show anything&lt;/P&gt;&lt;P&gt;Do u know how to change the query to accomplish those?&lt;/P&gt;&lt;P&gt;I am really extra appreciative for your help! Thank you very much!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 18:15:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/610016#M212123</guid>
      <dc:creator>djoobbani</dc:creator>
      <dc:date>2022-08-18T18:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: get the chart of count and percentage by, in one column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/610020#M212124</link>
      <description>&lt;P&gt;Sorry in the previous post i showed the incorrect picture.&lt;/P&gt;&lt;P&gt;Here is the correct picture for this query:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;| chart count by path_template, http_status_code | addtotals fieldname=total&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| foreach 2* 3* 4* 5* [ eval "percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=round(100*'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/total), "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'." (".'percent_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'."%)" ] | fields - percent_*&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-08-18 at 11.36.36 AM.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21092i5F7FD700677C5760/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-08-18 at 11.36.36 AM.png" alt="Screen Shot 2022-08-18 at 11.36.36 AM.png" /&gt;&lt;/span&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 18:38:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/610020#M212124</guid>
      <dc:creator>djoobbani</dc:creator>
      <dc:date>2022-08-18T18:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: get the chart of count and percentage by, in one column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/610264#M212220</link>
      <description>&lt;P&gt;Instead of your existing foreach block, replace it with this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach 2* 3* 4* 5* 
    [ eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=if('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'=total OR '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'=0, "", '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'."(".round(100*'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/total)."%)") ]&lt;/LI-CODE&gt;&lt;P&gt;that will only show a value if the field value is not equal to total or 0.&lt;/P&gt;&lt;P&gt;Add the fields - total to remove the total field at the end&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 01:36:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-chart-of-count-and-percentage-by-in-one-column/m-p/610264#M212220</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-08-22T01:36:05Z</dc:date>
    </item>
  </channel>
</rss>

