variably changing images that display in SSRS

  • Hello.

    In the visibility tab of Image properties I have used a switch statement:

    =SWITCH (Parameters!Site.Value = "Website1", "file1",

    Parameters!Site.Value = "Website2", "file2",

    Parameters!Site.Value = "Website3", "file3",

    Parameters!Site.Value = "Website", "file4",

    Parameters!Site.Value = "Website5", "file5",

    Parameters!Site.Value = "Website6", "file6",

    )

    Have alternately used an IIF statement:

    =IIF (Parameters!Site.Value = "Website1", "file1",

    Parameters!Site.Value = "Website2", "file2",

    Parameters!Site.Value = "Website3", "file3",

    Parameters!Site.Value = "Website", "file4",

    Parameters!Site.Value = "Website5", "file5",

    Parameters!Site.Value = "Website6", "file6",

    )

    But each time I get the following error:

    The hidden expression used in image 'Image 1' returned a data type that is not valid.

    The images themselves are in a folder on my local drive, same drive as BIDS 2008 is running on. I have tried the above statement against both external and embedded images. ie. imported them once by pulling them into my Reports as 'existing items' (r-click on Reports>add existing item>navigate to jpg file>OK). This is considered an external image source. I have also uploaded the images into the Report Data section of my report as 'images' (r-click Images>Add Image>navigate to local folder>open). This is considered embedded image source.

    Either way neither the SWITCH nor IIF statements have any effect on the image returned to the report during Preview. Desired outcome is that depending on the value entered for the parameter, the appropriate logo is loaded.

    Can someone explain procedure for variably loading images and or provide additional links?

  • The visibility expression has to return a boolean true/false value.

    The only way to get that to work would be embed all images & set the visibility flag on each individually, which I don't recommend.

    It'll be the expression on the General tab you need to use to determine which image to use.

    External or database images would be the way to go.

  • OK, I will use External images.

    I took the expression and pasted it to the General tab's Tooltip fx field. That returns an error: 'Enter a valid expression for initial visibility state'.

    I hit OK and it redirects me to Visibility tab.

    Are you saying my expression doesn't evaluate to true/false? Do I need an expression in both the Visibility and General tab?

  • Change Visibility back to Show radio button, as far as I can tell you don't need anything on that tab.

    The Switch statement you've posted I think will work, pretty sure the Iif won't - it'd need to be nested Iif statements for that logic.

  • I changed visibility to Show, put expression into the fx next to 'Use This Image' and is working. 😎

    Thanks gazareth!

  • No problem, thanks 🙂

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply