【发布时间】:2019-05-17 20:00:31
【问题描述】:
我正在尝试找到一种方法来获取特定日期范围之间的列的总和。 我有一个数据集,其中包含 2016 年至 2019 年的数据,并且想使用一个表来保存所有四年,以便以后进行交互式排序。我已经为 1/1/201x 和 12/31/201x 创建了具有设定值的参数。
这是我目前正在尝试的,但收到错误。
=IIF(Fields!TxnDate.Value >= Parameters!start2016.Value AND Fields!TxnDate.Value <= Parameters!end2016.Value, sum(Fields!Amount.Value),0)
错误
System.Web.Services.Protocols.SoapException: The Value expression for the text box ‘Total2016’ has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a dataset.
at Microsoft.ReportingServices.Library.ReportingService2010Impl.CreateReportEditSession(String Report, String Parent, Byte[] Definition, String& EditSessionID, Warning[]& Warnings)
at Microsoft.ReportingServices.WebServer.ReportingService2010.CreateReportEditSession(String Report, String Parent, Byte[] Definition, String& EditSessionID, Warning[]& Warnings)
我需要做什么才能让表达式对日期范围内列中的总金额求和?
注意:总金额将设置为货币。
【问题讨论】:
-
正如汉诺威指出的那样,IIF/SUM 表达式不正确,但您得到的错误是范围错误。你把这个表达式放在哪里?它是在表格/矩阵中还是仅在文本框中?如果它只是在文本框中,则需要根据要评估的内容添加范围,如果要对整个数据集进行求和/iff,则使用引号中的数据集名称作为范围
=SUM(IIF(Fields!X.Value > Parameters!myParameterName.Value, Fields!myValue.Value, 0), "myDataSetName")
标签: reporting-services expression reportbuilder