Calculate total and percentage columns from ssrs 2008 r2 dataset for reports.

ezkhan
ezkhan used Ask the Experts™
on
Hi,

I have a situation to calculate the total of a column in dataset in ssrs 2008 r2 to calculate percentage in another column.

e.g.,

ValueColumn       TotalColumn        PercentageColumn
20                            69                      20/69*100
33                            69                      33/69*100
46                            69                      46/69*100


I want to create TotalColumn and Percentage from SSRS 2008 R2 dataset (using calculated field or some other method not sure!!!!!!!!!!!)

Your help and  suggesionss are highly appreciated.

Thanks.

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
what does the raw sql query look like? What is the table structure? Is TotalColumn a calculated field, or is it something directly from the DB?

You might be able to do this:

SELECT ValueColumn, TotalColumn, ValueColumn/TotalColumn*100 AS PercentageColumn FROM DataTable

Author

Commented:


I can do it in db but these columns are not individual columns e.g.,

As per your select statment ValueColumn is derived from number of aggregagetes and divisions with 10 different columns in database dataset. If I calculate percentage again in database then i need to calculate ValueColumn twice and there more than one columns where i need to calculate percentage. It slows down the whole query and increases CPU usage.

Thats why I want to calculate percentage from already calculated columns in Reporting Services instead of DB.

Please suggest solution in reporting services. Your answers and suggestions are greatly appreciated.

Thanks
TotalColumn:
=Sum(Fields!ValueColumn.Value, "DataSetName")

Open in new window

PercentageColumn:
=Fields!ValueColumn.Value/Sum(Fields!ValueColumn.Value, "DataSetName")*100

Open in new window

OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Commented:
try this

 
=Sum(Fields!FieldName.Value,"DatasetName")

Open in new window

=Round((Fields!SrNo.Value/SUM(Fields!FieldName.Value,"Dataset")*100),2)

Open in new window

Alpesh PatelSolution Architect at TCS (SAFe®Agilist, TOGAF® Foundation, PSM I®, MCP, MCSD)

Commented:

Author

Commented:



Thanks a lot for your suggesions; I want to use this calculated percentage column in pie chart as series!!!!!!!!!

Is this possible???????????
If you want to use it on a pie chart, you don't need to calculate the percentage manually. Just drop the ValueColumn on the data field and it will automatically divide the chart as percentage. If you want to show the percentage as label, then you could select #PERCENT as the Label Data.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial