SQLTeam.com | Weblogs | Forums

Error in SSRS expression

sql2008r2

#1

I have a SSRS expression written for a images to be shown inside a report column .
In the image properties, the expression below is written, showing a error.
The expected result is like it should show more than one images in the report column, if more than one condition in the expression turns to be true. Thanks.

=IIF(Fields!GHS01.Value = "X", "GHS01", Nothing & ) &
IIF(Fields!GHS02.Value = "X", "GHS02", Nothing & ) &
IIF(Fields!GHS03.Value = "X", "GHS03", Nothing & ) &
IIF(Fields!GHS04.Value = "X", "GHS04", Nothing & ) &
IIF(Fields!GHS05.Value = "X", "GHS05", Nothing & ) &
IIF(Fields!GHS06.Value = "X", "GHS06", Nothing & ) &
IIF(Fields!GHS07.Value = "X", "GHS07", Nothing & ) &
IIF(Fields!GHS08.Value = "X", "GHS08", Nothing & ) &
IIF(Fields!GHS09.Value = "X", "GHS09", Nothing & ) &


#2

I have corrected my expression like this:

=IIF(Fields!GHS01.Value = "X", "GHS01", Nothing  )  & 
IIF(Fields!GHS02.Value = "X", "GHS02", Nothing   )  & 
IIF(Fields!GHS03.Value = "X", "GHS03", Nothing   )  & 
IIF(Fields!GHS04.Value = "X", "GHS04", Nothing   )  & 
IIF(Fields!GHS05.Value = "X", "GHS05", Nothing   )  & 
IIF(Fields!GHS06.Value = "X", "GHS06", Nothing   )  & 
IIF(Fields!GHS07.Value = "X", "GHS07", Nothing   )  & 
IIF(Fields!GHS08.Value = "X", "GHS08", Nothing   )  & 
IIF(Fields!GHS09.Value = "X", "GHS09", Nothing   )

But the expected result is like it should show more than one images in the report column, if more than one condition in the expression turns to be true. Is it possible? Please comment.


#3

Try replacing each

Nothing

with two double quotes instead

=IIF(Fields!GHS01.Value = "X", "GHS01", "" ) & etc.


#4

First off, it doesn't look like you did what I suggested. Putting NOTHING as the false result is going to make it all nothing. That's like taking a field value and adding null to it which results in a null. Second, I don't see where you are actually including the image. If the images are stored in a field in the database then you would need to reference the field value not a text value. I'm not clear as to how you have the images stored so I'm giving you the revised code but it will likely show a concatenated text value.

=IIF(Fields!GHS01.Value = "X", "GHS01", "" ) &
IIF(Fields!GHS02.Value = "X", "GHS02", "" ) &
IIF(Fields!GHS03.Value = "X", "GHS03", "" ) &
IIF(Fields!GHS04.Value = "X", "GHS04", "" ) &
IIF(Fields!GHS05.Value = "X", "GHS05", "" ) &
IIF(Fields!GHS06.Value = "X", "GHS06", "" ) &
IIF(Fields!GHS07.Value = "X", "GHS07", "" ) &
IIF(Fields!GHS08.Value = "X", "GHS08", "" ) &
IIF(Fields!GHS09.Value = "X", "GHS09", "" )