报表生成器 SUM IIF - 超过 1 个数据集 [英] Report Builder SUM IIF - More than 1 DataSet
问题描述
我正在尝试使用以下代码将以下表达式添加到 Report Builder 报告上的 TextBox:
I am trying to add the following expression to a TextBox on a Report Builder report using the following code:
=SUM(IIF(Fields!TaskDescription.Value,"DataSet1") = "Running", 1, 0)
我认为有 1 个以上的数据集导致了问题,但上面给出了以下错误消息:
I have more than 1 dataset which I think is causing the issue, but the above gives me the following error message:
scope 参数必须设置为一个字符串常量,等于包含组的名称,包含数据的名称区域,或数据集的名称.
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.
我做错了什么?
推荐答案
作用域,在你的例子中是数据集,需要是聚合中的最后一个参数,即在 IIf
之后:>
The Scope, in your case the DataSet, need to be the last parameter in the aggregate, i.e. after the IIf
:
=SUM(IIF(Fields!TaskDescription.Value = "Running", 1, 0), "DataSet1")
即=Sum(
该表达式计算 DataSet1
数据集中 TaskDescription
列中值 Running 的出现次数.
The expression counts the occurrences of the value Running in the TaskDescription
column in the DataSet1
DataSet.
评论后编辑
一个快速测试,显示了正在运行的表达式.带有您的列的简单数据集:
A quick test showing the expression in action. A simple DataSet with your column:
我刚刚使用上述表达式向空白报告添加了一个文本框:
I've just added a textbox to a blank report with the above expression:
在示例数据上按预期工作:
Works as expected on the sample data:
这篇关于报表生成器 SUM IIF - 超过 1 个数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!