SQL SSRS根据行总数计算列的百分比
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22205659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SSRS calculate percentage of column based on row total
提问by grahamie
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
我想计算每列(A,B)的总数作为行总数的百分比,看起来像
+-------+-----+-----+-------+
| 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:
我试过一个表和矩阵似乎无法正常工作:
回答by Ian Preston
Your % value expression should be something like:
你的 % value 表达式应该是这样的:
=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.
RowGroupName
您定义的Month
行组的名称在哪里,正如您在给出的示例中可能注意到的那样。
This applies the total Income
for a particular Fee_To
/ Month
group to all Fee_To
total Income
values in that Month
group.
这将Income
特定Fee_To
/Month
组的总计应用于该组中的所有Fee_To
总计Income
值Month
。