我正在尝试找到一种方法来获取特定日期范围内的列的总和。我有一个数据集,其中包含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)我需要做什么才能让表达式对日期范围内的列中的总金额求和?
注:合计金额将设置为货币。
发布于 2019-05-18 05:20:10
你只是想把你的金额移到IIF之外。
=SUM(IIF(Fields!TxnDate.Value >= Parameters!start2016.Value AND Fields!TxnDate.Value <= Parameters!end2016.Value, Fields!Amount.Value, 0))如果金额不是整数,则需要使用CDEC(0)将0转换为decimal,否则会出现Can't Aggregate Different Types错误。
你的日期是文本字符串吗?如果是mm/dd/yyyy格式的文本,您的评估可能无法正常工作。您可能需要转换为日期才能与CDATE进行比较。
https://stackoverflow.com/questions/56192845
复制相似问题