<?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 add total percentage to rows and columns in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313085#M93729</link>
    <description>&lt;P&gt;I tried the query but got an error. What exactly should I replace &lt;STRONG&gt;&amp;lt;&amp;gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&amp;lt;&amp;gt;&lt;/STRONG&gt; with?&lt;BR /&gt;
And what do &lt;STRONG&gt;categoryId&lt;/STRONG&gt; and  &lt;STRONG&gt;referer_domain&lt;/STRONG&gt; represent?&lt;/P&gt;</description>
    <pubDate>Sun, 03 Sep 2017 08:58:07 GMT</pubDate>
    <dc:creator>vshakur</dc:creator>
    <dc:date>2017-09-03T08:58:07Z</dc:date>
    <item>
      <title>How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313082#M93726</link>
      <description>&lt;P&gt;I have the following query :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | search service_name=$service$ | dedup name, jenkins_data.JOB_NAME, jenkins_data.UNIX_TIMESTAMP | stats count AS total, count(eval(status="PASS")) as success by service_name browser_name | eval rate = round(success/total*100,0). " %" |  chart values(rate) as result by service_name browser_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which produces the following table:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3440iD4395F7208309BF7/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I want to add a "&lt;STRONG&gt;Total&lt;/STRONG&gt;" both as a row and as a column at the end of the rows and columns in the table. &lt;BR /&gt;
Using &lt;STRONG&gt;addtotals&lt;/STRONG&gt; didn't achieve my goals since I don't need to calculate the total sum of the percentages (which would obviously produce a number greater than 100%).&lt;BR /&gt;
I need the &lt;STRONG&gt;total pass rate&lt;/STRONG&gt; both for the services and the browsers, i.e: ( (Passed Total) / (Grand Total) * 100 ) %.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 16:57:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313082#M93726</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-09-02T16:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313083#M93727</link>
      <description>&lt;P&gt;@vshakur, I could do Pass percent by each &lt;CODE&gt;service_name&lt;/CODE&gt;. However, in the same query I could not get to Pass percent by &lt;CODE&gt;browser_name&lt;/CODE&gt;. Please try out the following (until someone gets you a better query to even perform &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... 
| search service_name=$service$ 
| dedup name, jenkins_data.JOB_NAME, jenkins_data.UNIX_TIMESTAMP 
| chart count as total count(eval(status="PASS")) as success over service_name by browser_name 
| eval success=0, total=0
| foreach "success: *" "total: *"
    [eval "perc: &amp;amp;lt;&amp;amp;lt;MATCHSTR&amp;amp;gt;&amp;amp;gt;"=round(('success: &amp;amp;lt;&amp;amp;lt;MATCHSTR&amp;amp;gt;&amp;amp;gt;'/ 'total: &amp;amp;lt;&amp;amp;lt;MATCHSTR&amp;amp;gt;&amp;amp;gt;')*100,1)]
| foreach "success: *" 
    [eval success=success + '&amp;amp;lt;&amp;amp;lt;FIELD&amp;amp;gt;&amp;amp;gt;']
| foreach "total: *" 
    [eval total=total + '&amp;amp;lt;&amp;amp;lt;FIELD&amp;amp;gt;&amp;amp;gt;']
| eval perc= round((success/total)*100,1)
| fields - "success*" "total*"
| rename "perc: *" as "*"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Sep 2017 08:42:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313083#M93727</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-03T08:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313084#M93728</link>
      <description>&lt;P&gt;Thanks, I'll try that.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 08:45:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313084#M93728</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-09-03T08:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313085#M93729</link>
      <description>&lt;P&gt;I tried the query but got an error. What exactly should I replace &lt;STRONG&gt;&amp;lt;&amp;gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&amp;lt;&amp;gt;&lt;/STRONG&gt; with?&lt;BR /&gt;
And what do &lt;STRONG&gt;categoryId&lt;/STRONG&gt; and  &lt;STRONG&gt;referer_domain&lt;/STRONG&gt; represent?&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 08:58:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313085#M93729</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-09-03T08:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313086#M93730</link>
      <description>&lt;P&gt;I tried the query but got an error. What exactly should I replace &lt;STRONG&gt;FIELD&lt;/STRONG&gt; and &lt;STRONG&gt;MATCHSTR&lt;/STRONG&gt; with?&lt;BR /&gt;
And what do &lt;STRONG&gt;categoryId&lt;/STRONG&gt; and &lt;STRONG&gt;referer_domain&lt;/STRONG&gt; represent?&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 09:08:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313086#M93730</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-09-03T09:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313087#M93731</link>
      <description>&lt;P&gt;OK, now I understand. It worked perfectly as a separate query in Splunk, but I need it to be part of a dashboard, and that's where I get the error message: &lt;STRONG&gt;Unencoded&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 09:23:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313087#M93731</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-09-03T09:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313088#M93732</link>
      <description>&lt;P&gt;@vshakur, sorry I had missed using your field names &lt;CODE&gt;service_name&lt;/CODE&gt; and  &lt;CODE&gt;browser_name&lt;/CODE&gt;. I have corrected the query.&lt;/P&gt;

&lt;P&gt;For adding the query to your dashboard you need to escape &lt;CODE&gt;&amp;lt;&lt;/CODE&gt; and &lt;CODE&gt;&amp;gt;&lt;/CODE&gt; characters with &lt;CODE&gt;&amp;amp;lt;&lt;/CODE&gt; and &lt;CODE&gt;&amp;amp;gt;&lt;/CODE&gt; respectively. Please find the updated query for dashboard.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;&lt;/CODE&gt; and &lt;CODE&gt;&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;&lt;/CODE&gt; are parameter for &lt;CODE&gt;foreach&lt;/CODE&gt; command in Splunk. You can refer to documentation for details: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Foreach"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Foreach&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Please confirm if this solves your need and I will convert to answer so that you can accept. You can also up vote if this has helped you.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 09:53:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313088#M93732</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-03T09:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313089#M93733</link>
      <description>&lt;P&gt;Yes thank you, I managed. &lt;BR /&gt;
Indeed it has solved completely half of the problem. I'm still stuck with the other half (calculating total by browser).&lt;BR /&gt;
I would like to up-vote. Please convert to answer.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 09:57:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313089#M93733</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-09-03T09:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313090#M93734</link>
      <description>&lt;P&gt;I've managed to add the total by browser using addtotals . Now all my problems are solved.&lt;BR /&gt;
Please convert to answer so I could accept.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 10:25:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313090#M93734</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-09-03T10:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313091#M93735</link>
      <description>&lt;P&gt;@vshakur, you can upvote comments directly. Since your issue is not resolved completely, I will leave it as comment so that it remains flagged as unanswered for other Splunkers.&lt;/P&gt;

&lt;P&gt;May I know whether you want to display the final result as table or chart?&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 10:29:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313091#M93735</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-03T10:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313092#M93736</link>
      <description>&lt;P&gt;As a table. But I've already managed to solve the second part of my problems. You can post as answer and I'll accept.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 10:32:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313092#M93736</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-09-03T10:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313093#M93737</link>
      <description>&lt;P&gt;I thought addtotals would add total of percent which you did not want. But nevertheless, glad it worked and I was able to help. Please accept the answer.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 10:36:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313093#M93737</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-03T10:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313094#M93738</link>
      <description>&lt;P&gt;I added the addtotals before the calculations. This created a new row called "Total" with all the services summed up for each browser. Only then I proceeded with your solution (the for loops). This has produced the right percentage for all the rows (services), including the Total row.&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 10:44:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313094#M93738</guid>
      <dc:creator>vshakur</dc:creator>
      <dc:date>2017-09-03T10:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to add total percentage to rows and columns</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313095#M93739</link>
      <description>&lt;P&gt;Cheers !!!&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 11:59:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-total-percentage-to-rows-and-columns/m-p/313095#M93739</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-03T11:59:21Z</dc:date>
    </item>
  </channel>
</rss>

