简体   繁体   中英

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.

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM