[英]SSRS Expression to count the distinct number of items visible
Currently I'm using this expression in a cell above the column headers of a table: 当前,我在表的列标题上方的单元格中使用此表达式:
= "Num Days " & CountDistinct(Fields!Date.Value)
In the report designer this is the context of the expression: 在报表设计器中,这是表达式的上下文:
Here is what the result looks like: 结果如下所示:
The expression is working ok ie in the data set there are 60 distinct dates which is what the expression returns. 表达式可以正常工作,即在数据集中有60个不同的日期,这就是表达式返回的内容。 However there is a filter on the group (Date2) so that it only has 10 visible days in the tablix.
但是,组(Date2)上有一个过滤器,因此在Tablix中只有10个可见天。
How do I amend the expression to return just the dates that are visible? 如何修改表达式以仅返回可见的日期?
The easiest solution is to move the filter upstream: can you put the filter on the Dataset instead of the Tablix Group? 最简单的解决方案是将过滤器移到上游:您可以将过滤器放到数据集而不是Tablix组上吗? Then these rows won't be included in your total.
然后,这些行将不会包含在您的总计中。
Other options include custom code to keep a running tally of values, or putting a conditional in your aggregate expression, maybe something like: 其他选项包括自定义代码,以保持值的连续运行,或在聚合表达式中添加条件,例如:
= "Num Days " &
(COUNTDISTINCT( IIF(DateDiff("d", Fields!Date.Value, Now) <= 10, Fields!Date.Value, 1)) -1 )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.