Report Builder SUM IIF - More than 1 DataSet

孤街醉人 提交于 2019-12-25 08:32:20

问题


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)

I have more than 1 dataset which I think is causing the issue, but the above gives me the following error message:

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.

What am I doing wrong?


回答1:


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")

i.e. =Sum(<Expression>, <Scope>)

The expression counts the occurrences of the value Running in the TaskDescription column in the DataSet1 DataSet.

Edit after comment

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:



来源:https://stackoverflow.com/questions/21603534/report-builder-sum-iif-more-than-1-dataset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!