简体   繁体   English

SSRS - 添加总数的百分比?

[英]SSRS - add percentage of total?

I am just starting out in SSRS and have a dataset that looks like the below.我刚开始使用 SSRS,并且有一个如下所示的数据集。

在此处输入图像描述

I have built this in a matrix table like so我已经在这样的矩阵表中构建了它

在此处输入图像描述

I want to show what percentage each of the rows total is of the grand total, so for the attached image I would want to show what percentage 35 (counselling calls) is of 47 (total) and what percentage Legal calls (12) is of total (47)我想显示每行总计占总计的百分比,因此对于所附图片,我想显示 35(咨询电话)占 47(总计)的百分比以及法律电话(12)的百分比共 (47)

I have tried =Fields.Calls.Value/sum(Fields?Calls.Value) but that just gives me 100% for both?我试过 =Fields.Calls.Value/sum(Fields?Calls.Value) 但这只是给了我 100% 吗?

Would appreciate any help将不胜感激任何帮助

You need to specify the scope of your SUM() expressions.您需要指定SUM()表达式的 scope。

I'll briefly explain how scopes work and then get to the answer.我将简要解释作用域的工作原理,然后得出答案。

SSRS always evaluates an expression based on it's scope which is usually defined by the physical location of the expression within table/matrix. SSRS 总是根据它的 scope 来评估表达式,这通常由表/矩阵中表达式的物理位置定义。 As you can see from your design all 4 textboxes show the same expression, [SUM(Calls}] which in fact is actually =SUM(Fields.Calls.Value) . However they give different results because the scope of each is different. The first is in the category rowgroup and the month column group for example, the second one is in the category row group but in the total month group, and so on...从您的设计中可以看出,所有 4 个文本框都显示相同的表达式[SUM(Calls}]实际上是=SUM(Fields.Calls.Value) 。但是它们给出不同的结果,因为每个文本框的 scope 是不同的。例如,第一个在类别行组和月份列组中,第二个在类别行组中但在总月份组中,依此类推...

OK, now to the answer !好的,现在来回答!

Assumming假设

  1. your rowgroup is called 'CategoryGroup` (you will see the name in the rowgroup panel under the main designer)您的行组称为“CategoryGroup”(您将在主设计器下的行组面板中看到名称)
  2. your dataset is called DataSet1您的数据集称为DataSet1

You expression should be你的表情应该是

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

This basically reads..这基本上读..

Take the sum of the call column for all rows that are within the current CategoryRowgroup and divide by the sum of the call column across the whole dataset.取当前 CategoryRowgroup 中所有行的调用列的总和,然后除以整个数据集的调用列的总和。

Notes笔记

  • The scope names must be enclosed in quote and are case sensitive scope 名称必须用引号括起来并且区分大小写
  • The scope names must match either a row or column group, or a dataset name exactly. scope 名称必须与行组或列组或数据集名称完全匹配。
  • the , "CategoryGroup" scope argument can probably be omitted as this should be the scope of the textbox anyway. , "CategoryGroup" scope 参数可能可以省略,因为无论如何这应该是文本框的 scope。

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

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