Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS calculate percentage of column based on row total

I have a data set which looks like this

+------------+-----------------------------+
| user_name  |             role            |
+------------+-----------------------------+
| User A     |  Admin, System              |
| User B     |  Editor, Power User, System |
+------------+-----------------------------+

I would like to calculate the total of each column (A,B) as a percentage of the Row total to look like

+-------+-----+-----+-------+
| Month |  A  |  B  | TOTAL |
+-------+-----+-----+-------+
| Jan   | 90% | 10% | 100%  |
| Feb   | 90% | 10% | 100%  |
| Mar   | 75% | 25% | 100%  |
+-------+-----+-----+-------+

I have tried a Table and Matrix cant seem to get either to work:

enter image description here

like image 236
grahamie Avatar asked Mar 05 '14 18:03

grahamie


People also ask

How do I calculate a percentage for a particular column in SQL?

There is no built-in operator that calculates percentages in SQL Server. You have to rely on basic arithmetic operations i.e. (number1/number2 x 100) to find percentages in SQL Server.

How do I add a percentage to a column in SSRS?

After that, you can follow Syed's suggestion to change the “Category:” to “Percent” in the Number tab of the Text Box Properties dialog. If it is a field in the details row of the “CountryTotal” column like “=Fields! SalesAmount”, then you can set the expression in the details row of the third column to “=Fields!

How do you find the percentage of a group in a total?

To calculate x percent of y: Divide x by 100. Multiply x by y. The resultant number is x% of y.


1 Answers

Your % value expression should be something like:

=Sum(Fields!Income.Value) / Sum(Fields!Income.Value, "RowGroupName")

Where RowGroupName is the name of your defined Month row group, as you may notice with the example given.

This applies the total Income for a particular Fee_To / Month group to all Fee_To total Income values in that Month group.

like image 114
Ian Preston Avatar answered Sep 23 '22 04:09

Ian Preston