user2478694
user2478694

Reputation: 1

SSRS expression issue using iif function

I have a data set that is returning two properties, a name and a total units. I am trying to set an iif expression on a data bar where iif(field!Name.Value = "Name", field!Total.Value, 0)

this is not working I get an error of rsFieldReferanceAmbiguous, the fields refers without specifying a dataset aggregate. And the only option that it gives me as an aggregation is First, but I do not want to get the first name, I want the bar to display the total units base on the name field that is in the iif expression.

Upvotes: 0

Views: 734

Answers (3)

Audo
Audo

Reputation: 135

Make sure your tablix has the dataset specified under General -> DataSetName on the properties pane. If you have more than one data set on the report you will need to specify which data set your reffering to like so: (Fields!Name.Value, "NameDataSet") If your useing tables you may need to ckeck if you have grouping and if so how your grouping your data.

Upvotes: 0

StevenWhite
StevenWhite

Reputation: 6034

The function you are trying to use would be better suited to a calculated field in your dataset. Then you can just refer that that field in your report. This allows you to filter the data line by line instead of by groups.

  1. Right-click on the dataset and go to Dataset Properties.
  2. Go to Fields.
  3. Click Add then Calculated Fields.
  4. Enter the name of the field and then the expression here.

Upvotes: 0

Chris Latta
Chris Latta

Reputation: 20560

rsFieldReferenceAmbiguous refers to trying to match something that is not in local scope. Therefore you have to aggregate it. You are probably wanting something like this:

=Sum(IIF(Fields!Name.Value = "Name", Fields!Total.Value, 0))

Upvotes: 0

Related Questions