0
votes

I have a requirement to display either of two images based on a condition. The expression I have used for the image is as below.

     Image1  =IIF(Fields!Field1.Value= 269, "checked", "unchecked")
     Image2  ==IIF(Fields!Field1.Value= 270, "checked", "unchecked")

The dataset returning the values for Field1 can return more than 1 rows but the above expression takess the value only from the 1st row that the dataset returns. How can I modify by expression so that it checks all the rows that my dataset returns i.e. is there any way to iterate through all the rows returned by the dataset and write an expression.

1
so are you not displaying the image in any tablix? - KrazzyNefarious
it is in a tablix only - user3383390
You need to explain in more detail what you are trying to achieve. Are these images displayed in each row of your tablix or in the tablix header? It's not clear to me why you need to iterate through all rows in a dataset. - Nathan Griffiths
The requirement is to display four check boxes based on the value in the field1. The four check boxes are present in the 4 rows of the tablix. The expression provided in the question has been used for the four images. My dataset returns 4 rows of data with the field1 containing 4 values such as 269,270,271,272 and when I run the report my expression just takes the field1 value from the 1st row the dataset returns and does not check the other rows. Therefore, even if values for the other images exist, it still does not check them. - user3383390
If Field1 is in the Detail section of the table and is being repeated for each row in the Dataset (for four rows) then Fields!Field1.Value should return the value of the current row, not the first row. Therefore it sounds like you have the expression in either the header or footer of the table, or somewhere else outside the detail section. - Nathan Griffiths

1 Answers

0
votes

You can nest an IIF condition in an aggregate to check against all values in the scope:

=MIN(IIF(Fields!Field1.Value= 269, "checked", "unchecked"))

In this expression, either "checked" or "unchecked" is being returned for each Field1.Value. If one or more of those values is "checked", "checked" will be returned because "checked" is alphabetically less than "unchecked".

Other aggregate functions can be used with a nested IIF to check against all records in a scope, but this one seems to be the simplest for what you are trying to do here.