Ok, this post is dedicated to all those zillion questioners asking how to use embedded images on your report based on a condition. Yet again, I will be making use of my favourite dataset from AdventureWorks – Order Count by Product (people who are following me would understand that this is the same dataset that has been featuring in many of my blogs. I admit it guys, I am too lazy to make a new dataset. On second thoughts, this doesn't look that bad, considering I have created a re-usable component in the form of my dataset. Woah, high fives!)
For making this report, I am going to make use of three images mainly:-
a) Home b) Thumbs Up c) Thumbs Down
The home image would just be used in the top left of the report, which could be used for hyper linking to the home page. The other 2 images would be used in a matrix, and would be displayed based on a condition.
(P.S. : This report is made in SSRS 2008, although the steps are quite similar in SSRS 2005 also)
To make the report, follow the steps below:-
1) On the Report Data panel, go to Images and right click on it. Click on Add Image and select the images you need to embed by giving the source path.
2) Once you have uploaded the 3 images, drag and drop Home image from the report data to the body of the report and press ok on the popup that appears (This is one method to bring embedded images in your layout)
3) Make a matrix underneath the Home image like shown in the figure below
4) Now the matrix will be having Products on it’s rows and order counts on it’s columns. Now let us add the Thumbs up image for the row which has the highest value of Order Count and the Thumb down image for the row which has the least value for Order Count. For this, go to the toolbox and drag and drop the Image tool to the vacant column in the right end of the matrix (This is the second method to bring embedded images in your layout). You would be getting the Image Properties popup on doing this. Click on the expression symbol in the image name.
5) Once you get the Expression editor open, enter the following expression:-
where thumbsup and thumbs_down are the names of the images embedded in the report. Notice that they are enclosed in double quotes. Also notice that if none of the conditions are true, empty string would be displayed.
6) Save the report and deploy it. Now you should be able to preview the report in internet explorer.
This is all it takes to embed images in your reports and use them. You can use them for a wide variety of purposes, though I usually use them for showing indicators or for using them as hyperlinks. However, if you want to store images in your database and use them in your reports, you might want to check out this post.