Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reporting services 带where子句的报表生成器3.0计数_Reporting Services_Report_Builder_Reportbuilder3.0 - Fatal编程技术网

Reporting services 带where子句的报表生成器3.0计数

Reporting services 带where子句的报表生成器3.0计数,reporting-services,report,builder,reportbuilder3.0,Reporting Services,Report,Builder,Reportbuilder3.0,对于我们的一个报告,我试图获得列被值1取消的行数。在过去,我使用我在Stackoverflow上找到的解决方案,将Sum函数与IIF一起使用,即 =Sum(iif(Fields!Canceled.Value="True", 1, 0)) 但是现在我的源数据对于一个预订id有多行,所以我需要在该列上添加一个distinct。在SQL中,我很容易做到 SELECT COUNT(DISTINCT(booking_id)) FROM Booking WHERE Canceled=1 但我不知道如何在

对于我们的一个报告,我试图获得列被值1取消的行数。在过去,我使用我在Stackoverflow上找到的解决方案,将Sum函数与IIF一起使用,即

=Sum(iif(Fields!Canceled.Value="True", 1, 0))
但是现在我的源数据对于一个预订id有多行,所以我需要在该列上添加一个distinct。在SQL中,我很容易做到

SELECT COUNT(DISTINCT(booking_id)) FROM Booking WHERE Canceled=1

但我不知道如何在ReportBuilder3.0中获得相同的行为。有什么想法吗?

如果可能的话,按照评论中的建议在T-SQL中执行此操作不是一个坏主意,但您可以在报告中使用以下表达式执行此操作:

=CountDistinct(IIf(Fields!Canceled.Value = 1, Fields!booking_id.Value, Nothing))

CountDistinct
将忽略
Nothing
(即Null)记录,因此您可以将
CountDistinct
应用于
IIf
表达式,该表达式返回
booking\u id
Nothing
,基于
取消的

我不确定您能否在报告中执行此操作。如果数据源是一个SQL查询,我同意Tab的说法——用SQL来做——如果你需要帮助或者不使用查询作为你的查询,请告诉我们datasource@Sander,这有帮助吗?