Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Percentage Calculation in Metrics Report. Expand / Collapse
Posted Friday, May 2, 2014 1:13 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, May 2, 2014 12:58 PM
Points: 1, Visits: 0
Hi All,

12/3/2013 12/4/2013
Measure value percentage value percentage
Failed 100 percent 1 200
Delivered 100 percent 2 200
Unknown 100 percent 3 200
Total 300 600

i have a metric report as above and need to calculate the percentage.
The Dataset has the following fields - Measure and Value.

percent 1 should be calculated as failed/(Unknown+Total) i.e 100/(100+300)
Percent 2 should be calculated as delivered/(Unknown+Total) i.e 100/(100+300)
Percent 3 should be calculated as Unknown(Unknown+Total) i.e 100/(100+300)

This is a metric report not a tabular report.
Help Please.


  Post Attachments 
report.JPG (12 views, 26.60 KB)
Post #1567160
Posted Wednesday, May 7, 2014 4:50 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, November 18, 2016 1:24 AM
Points: 3,662, Visits: 1,510
This is a common requirement, to calculate the percentage of total given a list of values.

The normal calculation would be : Percentage of Total = ThisValue / Total

Your calculations look strange as the Unknown value is included twice (once in the total and once where you use the Unknown+Total as the divisor).

Given the normal requirement in a matrix (columns are Date, Metric and Value).

1. Add the matrix to the report as normal (gives 2 by 2 grid)
2. Drag the Date column onto the first row, second column. This will repeat for each date and gives a column group called Date which will be used later.
3. Drag the Metric column onto the second row, first column. This will repeat for each metric and gives a row group called Metric.
4. Drag the Value column on the second row, second column. The expression will be


5. Test the report shows the values in the correct way.
6. In design mode, right click the Value cell and choose to Insert Column inside group to the right. This will be the cell for the percentage.
7. Right click the new cell and choose to add an Expression, as below. This would give the total for the complete Date (refers to the column group name).

=SUM(Fields!Value.value) / SUM(Fields!Value.value, "Date")

8. Format the cell to percentage.
9. Right click the Date column heading and choose to Insert Row inside group below. Split the new cell that is created. Name the headings Value and Percentage.



(Measure and Percentage.txt is a example RDL)

  Post Attachments 
SampleReport_output.png (12 views, 4.57 KB)
Measure and Percentage.txt (7 views, 27.35 KB)
Post #1568374
Posted Wednesday, June 11, 2014 4:19 PM

SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: 2 days ago @ 7:30 PM
Points: 994, Visits: 1,935
You can also include the percent/ratio in your sql query and pass it as a column to the report via the result set.

Example ::


personType, count(*) as Total, round( (cast(count(*) as float)/ (SELECT count(*) from person.person) ),3)*100 as PercentOfTotal
from person.person
Group by personType

This can help you get started. Make sure count(*) > 0

How to post forum questions to get the best help
Post #1579842
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse