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?

有帮助吗?

解决方案

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:

enter image description here

enter image description here

I've just added a textbox to a blank report with the above expression:

enter image description here

enter image description here

Works as expected on the sample data:

enter image description here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top