问题
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