7
votes

Im building a report that's using two datasets. when I preview I find these types of errors...

Error 19
[rsFieldReferenceAmbiguous]
The Value expression for the text box ‘Textbox3’ refers directly to the field ‘PerZipCode’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope.

What aggregate function is needed and where is there an option to set this?

4

4 Answers

7
votes

Min or Max or Avg etc: most of these

The aggregate is needed to reduce the other DataSet to one value (max of values etc) because you are using something not in the local scope (eg the DataSet bound to the Data Region). There is no way to match rows in the other DataSet with the local scope DataSet.

If your text box is standalone (not in a Data region), the same applies: the aggregate is needed to tell SSRS which row to take (Max etc) or what calculation to do on the dataset (Avg etc)

8
votes

If you are adding multiple datasets to a report, the above may not fix your problem. You may just get the following error when you aggregate it:

[rsMissingAggregateScope] The Value expression for the text box ‘textbox6’ uses an aggregate expression without a scope. A scope is required for all aggregates used outside of a data region unless the report contains exactly one dataset.

What you may need is something like :

First(Fields!MyField.Value, "DATASETNAME")

Which you can get by using the Expression Builder, rather than the drag and drop of fields from the dataset.

0
votes

To use multiple dataset value on SSRS report we need to use below code.

First(Fields!MyField.Value, "Datasetname").

If by typing this you are still getting the same problem then right click on textbox & select expressions then in expressions click on Dataset. Select you dataset & then double click on required column. After this click on ok.

If you have multiple controls then follow the same for all of them & verify the same by executing the report.

0
votes

If you already have an aggregate and are having this error, it is probably because the fields of the report aren't up to date with the dataset(s). You can fix the issue by refreshing the fields of the report.

To populate the field collection, use the Refresh Fields button on the Dataset Properties dialog box. The field collection does not appear in the Report Data pane until the Dataset Properties dialog box closes.

To refresh the fields for a specific dataset In the Report Data pane, right-click the dataset, and then click Dataset Properties.

Note : If the Report Data pane is not visible, on the View menu, click Report Data. If the pane opens as a floating window, you can dock it. For more information, see How to: Dock the Report Data Pane.

In the Query pane, type the query. Alternatively, you can use the Import button to import your query from another .rdl file. Click Refresh Fields. Click OK. In the Report Data pane, expand the dataset node to view the currently defined field collection.