<?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 Calculating percentage in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291003#M40362</link>
    <description>&lt;P&gt;What is the spl command to calculate percentage of an field in splunk.&lt;BR /&gt;
Using dbxquery to display field values from database table. Need to know the command to display percentage of an database table column values.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2017 14:58:11 GMT</pubDate>
    <dc:creator>kishen2017</dc:creator>
    <dc:date>2017-11-20T14:58:11Z</dc:date>
    <item>
      <title>Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291003#M40362</link>
      <description>&lt;P&gt;What is the spl command to calculate percentage of an field in splunk.&lt;BR /&gt;
Using dbxquery to display field values from database table. Need to know the command to display percentage of an database table column values.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 14:58:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291003#M40362</guid>
      <dc:creator>kishen2017</dc:creator>
      <dc:date>2017-11-20T14:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291004#M40363</link>
      <description>&lt;P&gt;Could you explain more about your current output and expected output, probably with some sample data?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 15:11:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291004#M40363</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-11-20T15:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291005#M40364</link>
      <description>&lt;P&gt;if you have a column that is already a percentage, you can format the column using the UI to add a &lt;CODE&gt;%&lt;/CODE&gt;&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/Viz/TableFormatsFormatting#Format_table_columns"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/Viz/TableFormatsFormatting#Format_table_columns&lt;/A&gt;&lt;BR /&gt;
or in the code of the dashboard&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/Viz/TableFormatsXML#Number_format_rules"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/Viz/TableFormatsXML#Number_format_rules&lt;/A&gt;&lt;BR /&gt;
or in the query:&lt;BR /&gt;
&lt;CODE&gt;|fieldformat fieldname=fieldname."%"&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;|eval fieldname=fieldname."%"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;if you need to actually create a percentage:&lt;BR /&gt;
&lt;CODE&gt;|eval percentage=round((field1/field2)*100,2)."%"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 15:44:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291005#M40364</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-11-20T15:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291006#M40365</link>
      <description>&lt;P&gt;Expected Output:&lt;/P&gt;

&lt;P&gt;Severity        Closed  Deferred Fixed   In UAT Returned Validated  Total&lt;BR /&gt;
1 - Critical    7      0           0       1              2             36     55&lt;BR /&gt;
2 - High           29     11         13    5              7             57    169&lt;BR /&gt;
3 - Medium  69    12         11    3             3             107    253&lt;BR /&gt;
4 - Low     17     6          3    3             0              22    55&lt;BR /&gt;
Total       122   29         27   12           12              222    532&lt;BR /&gt;
Percentage  23%    6%    4%   2%        5%             40%  &lt;/P&gt;

&lt;P&gt;Current Output:&lt;/P&gt;

&lt;P&gt;Severity        Closed  Deferred Fixed   In UAT Returned Validated  Total&lt;BR /&gt;
1 - Critical    7      0           0       1              2             36     55&lt;BR /&gt;
2 - High           29     11         13    5              7             57    169&lt;BR /&gt;
3 - Medium  69    12         11    3             3             107    253&lt;BR /&gt;
4 - Low     17     6          3    3             0              22    55&lt;BR /&gt;
Total       122   29         27   12           12              222    532&lt;/P&gt;

&lt;P&gt;Query used:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbxquery query="SELECT BG_PROJECT 'Project', BG_USER_05 'Project_ID', BG_BUG_ID, BG_STATUS 'Status', BG_SEVERITY 'Severity', BG_DETECTION_DATE 
FROM defect connection="Test" shortnames=1             
| chart count over Severity by Status limit=0             
| addtotals labelfield="Severity" fieldname="Total"              
| addcoltotals labelfield="Severity" label="Grand Total"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Need to know how to get that percentage row as mentioned in expected output&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 16:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291006#M40365</guid>
      <dc:creator>kishen2017</dc:creator>
      <dc:date>2017-11-20T16:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291007#M40366</link>
      <description>&lt;P&gt;@kishen2017, You should provide more details as requested by Somesh. If possible, you should also add your current SPL with dbxquery to get the DB field for percent and also provide the field name on which to calculate percent.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbxquery &amp;lt;YourQuery&amp;gt;
| table Your_DB_Field
| eventstats sum(Your_DB_Field) as Total
| eval perc=round((Your_DB_Field/Total)*100,1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2017 16:38:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291007#M40366</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-20T16:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291008#M40367</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbxquery query="SELECT BG_PROJECT 'Project', BG_USER_05 'Project_ID', BG_BUG_ID, BG_STATUS 'Status', BG_SEVERITY 'Severity', BG_DETECTION_DATE 
FROM defect connection="Test" shortnames=1 
| stats count by Severity Status
| appendpipe [| stats sum(count) as count by Status | eval Severity="5 - Total"]
| appendpipe [| where Severity="5 - Total" | eventstats sum(count) as Total | eval count=round(count*100/Total)."%" | eval Severity="6 - Percentage" | table Severity Status count]
| xyseries Severity Status count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2017 17:03:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291008#M40367</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-11-20T17:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291009#M40368</link>
      <description>&lt;P&gt;Okay, you are wasting a bunch of CPU and IO with that query.  You only need Status and Severity, and you are bringing back a whole bunch of other druck. &lt;/P&gt;

&lt;P&gt;This is your SQL: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SELECT 
   BG_PROJECT 'Project', 
   BG_USER_05 'Project_ID', 
   BG_BUG_ID, 
   BG_STATUS 'Status', 
   BG_SEVERITY 'Severity', 
   BG_DETECTION_DATE 
FROM defect
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the only SQL you need:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SELECT 
   BG_STATUS 'Status', 
   BG_SEVERITY 'Severity'
FROM defect
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And really, you could have the SQL do the summary work, rather than shipping back the individual records for splunk to add up.  The SQL would look like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SELECT 
   BG_STATUS 'Status', 
   BG_SEVERITY 'Severity', 
   Count(*) as Count
FROM defect
GROUP BY BG_STATUS, BG_SEVERITY  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...and the whole thing would look like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbxquery query="SELECT BG_STATUS as 'Status', BG_SEVERITY as 'Severity', Count(*) as 'Count' 
     FROM defect GROUP BY  BG_STATUS, BG_SEVERITY" connection="Test" shortnames=1 
| table Severity Status Count
| appendpipe [
    | stats sum(Count) as Count by Status 
    | eval Severity="5 - Total"
    ]
| appendpipe [
    | where Severity="5 - Total" 
    | eventstats sum(Count) as Total 
    | eval Count=round(Count*100/Total)."%" 
    | eval Severity="6 - Percentage" 
    | table Severity Status Count]
| xyseries Severity Status Count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;NOTE - There should be a closing quote after the query in the code you posted.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 17:52:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291009#M40368</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-11-20T17:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291010#M40369</link>
      <description>&lt;P&gt;@kishen2017, you are calculating a total of row and total of column and expect to calculate percent on the basis of Total value also as a field, which to me is a bit confusing.&lt;/P&gt;

&lt;P&gt;If you are on &lt;CODE&gt;Splunk Enterprise 6.5 or higher&lt;/CODE&gt;, the feature to Add &lt;CODE&gt;Summary Total and Percent&lt;/CODE&gt; is built in to Splunk. You can do it via &lt;/P&gt;

&lt;P&gt;1) &lt;CODE&gt;Splunk UI &amp;gt; Edit Table &amp;gt; Format&lt;/CODE&gt; option to Add Total and/or Percent Summary row/s&lt;/P&gt;

&lt;P&gt;Refer to documentation: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Viz/TableFormatsFormatting#Summary_row_examples"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Viz/TableFormatsFormatting#Summary_row_examples&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;2) Or though &lt;CODE&gt;Table Simple XML Configuration&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;table&amp;gt;
     ...
     ...
    &amp;lt;option name="percentagesRow"&amp;gt;true&amp;lt;/option&amp;gt;
    &amp;lt;option name="totalsRow"&amp;gt;true&amp;lt;/option&amp;gt;
  &amp;lt;/table&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2017 18:17:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291010#M40369</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-20T18:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291011#M40370</link>
      <description>&lt;P&gt;Thank you so much for your inputs&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 18:38:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291011#M40370</guid>
      <dc:creator>kishen2017</dc:creator>
      <dc:date>2017-11-20T18:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291012#M40371</link>
      <description>&lt;P&gt;Thank you so much for your inputs&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 18:38:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291012#M40371</guid>
      <dc:creator>kishen2017</dc:creator>
      <dc:date>2017-11-20T18:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291013#M40372</link>
      <description>&lt;P&gt;Thank you so much for your inputs&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 18:38:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291013#M40372</guid>
      <dc:creator>kishen2017</dc:creator>
      <dc:date>2017-11-20T18:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291014#M40373</link>
      <description>&lt;P&gt;Thank you somesoni2 for your inputs. &lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 18:40:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291014#M40373</guid>
      <dc:creator>kishen2017</dc:creator>
      <dc:date>2017-11-20T18:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291015#M40374</link>
      <description>&lt;P&gt;@kishen2017, if one of the answers below has helped you resolve the issue you were facing, please accept the answer to mark this question as aswered. I see that you have already up voted the answers.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 04:19:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Calculating-percentage/m-p/291015#M40374</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-24T04:19:59Z</dc:date>
    </item>
  </channel>
</rss>

