SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Percentage Calculation in Metrics Report.


Percentage Calculation in Metrics Report.

Author
Message
sunitarani19
sunitarani19
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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.

Thanks
Rani
Attachments
report.JPG (14 views, 26.00 KB)
Mark Fitzgerald-331224
Mark Fitzgerald-331224
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3979 Visits: 1603
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

=SUM(Fields!Value.value)

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.

Done

Fitz

(Measure and Percentage.txt is a example RDL)
Attachments
SampleReport_output.png (17 views, 4.00 KB)
Measure and Percentage.txt (10 views, 27.00 KB)
MMartin1
MMartin1
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3819 Visits: 2031
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 ::



USE ADVENTUREWORKS2008R2;
Go


SELECT
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 :-D

----------------------------------------------------
How to post forum questions to get the best help
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search