SSRS 占总数的百分比

问题描述:

我希望能够获得每一行与整个总数的关系的百分比.这是我的公式:

I would like to be able to get the percentage of each row with relation of the whole total. Here is my formula:

=COUNTDISTINCT(Fields!ID.Value, "NameOfRowGrouping") / COUNTDISTINCT(Fields!ID.Value, "TopLevelGroupName")

出来的百分比是行总数与每组总数的百分比:

The percentage it comes out is the percentage between row total and total of each group:

Group       Qty     %
---------------------
Group 1
MemberA       3   40%
MemberB       4   60%

Total         7

Group 2 
MemberC       2   50%
MemberD       2   50%

Total         4

Grand Total  11

我需要知道所有分组的百分比与总数的关系,如下所示:

I need to know the percentage with relation of the total for all groupings, like so:

Group       Qty     %
---------------------
Group 1
MemberA       3   30%
MemberB       4   40%

Total         7

Group 2 
MemberC       2   15%
MemberD       2   15%

Total         4

Grand Total  11  100%

听起来你想做的是基于数据集计算,而不是表分组:

It sounds like what you want to do is calculate based on the dataset, not the table grouping:

=CountDistinct(Fields!ID.Value)/CountDistinct(Fields!ID.Value, "MyDatasetName")