简体   繁体   English

如何在SSRS中对聚集进行分组和过滤

[英]how to group and filter on aggregate in SSRS

I have a requirement to report the number of people who have more than one record in the dataset for my SSRS report and I can't quite get how to filter on the grouping. 我需要为我的SSRS报告报告在数据集中有多个记录的人数,但我还不太了解如何对分组进行过滤。

So if the dataset results are: 因此,如果数据集结果为:

ID     PersonID    FileID
1      1234         abc
2      7890         ade
3      5647         aer
4      1234         xyz

I would like to report 1. There is one person who has more than 1 record. 我想报告1.一个人的记录超过1个。

Is there an expression or something I can use to do this? 是否有表达或我可以用来做的事情?

Thank you. 谢谢。

You can use LookupSet and CountDistinct function to get the required count, however you will need the textbox used to show the calculation be in a scope. 您可以使用LookupSet和CountDistinct函数获取所需的计数,但是您将需要用于显示计算的文本框在范围内。

If you want to show the number of persons with more than one record as a total in your table use this expression: 如果要在表中显示总共有一个以上记录的人数,请使用以下表达式:

=CountDistinct(
IIF(
  LookupSet(
    Fields!PersonID.Value,Fields!PersonID.Value,
    Fields!ID.Value,"DataSetName"
  ).Length>1,Fields!PersonID.Value,Nothing)
)

Set it outside any group scope: 将其设置在任何组范围之外:

在此处输入图片说明

However if you want to show the number of persons with more than one record outside your tablix in a textbox, you can add an additional tablix and delete the necessary rows and columns to leave only one textbox then set the dataset property to the dataset name you are using and use the same expression. 但是,如果要在文本框中显示在Tablix之外具有多个记录的人数,则可以添加其他Tablix并删除必要的行和列,以仅保留一个文本框,然后将dataset属性设置为您的数据集名称正在使用并使用相同的表达式。

在此处输入图片说明

It should produce: 它应该产生:

在此处输入图片说明

Note my dataset has more rows to ilustrate the functionality. 请注意,我的数据集包含更多行以说明功能。 In the right side there is only one textbox with the count. 在右侧,只有一个带有计数的文本框。

Let me know if this helps. 让我知道是否有帮助。

If you want the result to be something like shown below. 如果您希望结果如下所示。

Steps: 脚步:

  1. Create a group on Person ID 在人员ID上创建组
  2. Right Click on Group > Add Total > Before
  3. Add a column and put =Count(Fields!PersonID.Value) 添加一列并放入=Count(Fields!PersonID.Value)
  4. If you want to display only Persons having more than one, set the visibility property of the tablix row. 如果只想显示具有多个角色的人员,请设置tablix行的可见性属性。

在此处输入图片说明

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

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