简体   繁体   English

占列总 SSRS 矩阵的百分比

[英]% of Column Total SSRS Matrix

I'm trying to display an SSRS row subgroup value as a percentage of its column total grouped by the row subgroup.我正在尝试将 SSRS 行子组值显示为按行子组分组的列总数的百分比。

My goal:我的目标:

1

Notice how the values in red display as a percentage of the value in the RowSubGroupTotal, whereas the RowSubGroupTotal displays as percentage of the ColumnGroup total.请注意,红色值如何显示为 RowSubGroupTotal 中值的百分比,而 RowSubGroupTotal 显示为 ColumnGroup 总数的百分比。

What I currently have:我目前拥有的:

在此处输入图像描述

The red values display as a percentage of the ColumnGroup total (just like the RowSubGroupTotals do).红色值显示为 ColumnGroup 总数的百分比(就像 RowSubGroupTotals 一样)。

How do I change those red values to rollup to 100% - their values as a percentage of the RowSubGroupTotal?如何将这些红色值更改为汇总到 100% - 它们的值占 RowSubGroupTotal 的百分比?

My matrix:我的矩阵:

在此处输入图像描述

Raw data: RawData原始数据: RawData

I want the red values to be a percentage of the RowSubGroupTotal (3/4 = 75%, 1/4 = 25%).我希望红色值是 RowSubGroupTotal 的百分比(3/4 = 75%,1/4 = 25%)。 I want the RowSubGroupTotal to be a percentage of the column subtotal (4/25 = 16%, 9/25 = 36%).我希望 RowSubGroupTotal 是列小计的百分比(4/25 = 16%,9/25 = 36%)。

Assuming the field is called Amount , your outer row group is called BlueRowGroup and your dataset is called 'DataSet1` then the expression for the red rows would be something like假设该字段称为Amount ,您的外部行组称为BlueRowGroup并且您的数据集称为“DataSet1”,那么红色行的表达式将类似于

=SUM(Fields!Amount.Value) / SUM(Fields!Amount.Value, "BlueRowGroup")

and the blue rows would be蓝色的行是

=SUM(Fields!Amount.Value) / SUM(Fields!Amount.Value, "DataSet1")

The first part of the expression does not state the scope as this will be the scope of the textbox the expression resides in. The second part states the scope of the total amount we want to divide by, so for the red rows, we want to divide the amount by the total amount from the next group up ( BlueRowGoup ). The first part of the expression does not state the scope as this will be the scope of the textbox the expression resides in. The second part states the scope of the total amount we want to divide by, so for the red rows, we want to将金额除以下一组的总金额( BlueRowGoup )。 For the blue rows we want the amount to be divided by the total for the entire dataset so we use the dataset name as the scope.对于蓝色行,我们希望将金额除以整个数据集的总数,因此我们使用数据集名称作为 scope。

Here is a working exmaple....这是一个工作示例....

I created some data to mirror your sample data, just changed the names to avoid confusing fields with groups/scopes.我创建了一些数据来镜像您的示例数据,只是更改了名称以避免将字段与组/范围混淆。

DECLARE @t TABLE(RowGroup varchar(10), SubGroup varchar(10), Amount int)
INSERT INTO @t VALUES 
('Alpha', 'Red', 2),
('Alpha', 'Red', 1),
('Alpha', 'Green', 0),
('Alpha', 'Blue', 1),
('Bravo', 'Red', 1),
('Bravo', 'Green', 0),
('Bravo', 'Blue', 4),
('Bravo', 'Blue', 4),
('Charlie', 'Red', 0),
('Charlie', 'Green', 4),
('Charlie', 'Blue', 2),
('Charlie', 'Blue', 6)

SELECT * FROM @t

I added a simple tablix showing both the actual underlying numbers and the %'s, which looks like this.我添加了一个简单的 tablix,显示了实际的基础数字和 %,看起来像这样。

在此处输入图像描述

I set the expression as earlier in this answer.我在这个答案中设置了表达式。

This gives the following result...这给出了以下结果......

在此处输入图像描述

In general you can use ReportItems expressions to create the ratios.通常,您可以使用 ReportItems 表达式来创建比率。 In any case you dont need the original values you can use hidden columns to make the calculations在任何情况下,您都不需要原始值,您可以使用隐藏列进行计算

Your expression could be like你的表情可能是

vs rowgroup1 total (yellow) vs rowgroup1 总计(黄色)

=Sum(Fields!val.Value) / ReportItems!Textbox9.Value 

vs rowgroup2 total (orange) vs rowgroup2 总计(橙色)

=Sum(Fields!val.Value) / ReportItems!Textbox12.Value 

For the ReportItem reference use the related cell name对于 ReportItem 引用,请使用相关的单元格名称

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM