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:-
=iif(Fields!Order_Count.Value=max(Fields!Order_Count.Value,"DataSet1"),"thumbsup",iif(Fields!Order_Count.Value=min(Fields!Order_Count.Value, "DataSet1"),"thumbs_down",""))
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.
Hi,
ReplyDeleteThanks for your post. I have an image and on that image i have some text boxes. This is image is visible on a condition. When the image is hidden, the report looks good. but when the image is visible, all the text boxes are moving down to next page. The main thing is this is happening only in report server 2008 and not in 2005. Please reply me @ srikanthreddyn143@yahoo.com
Thanks
Sri
Hi Sree,
ReplyDeleteOverlapping objects are not supported when SSRS reports are rendered in formats like html. So if you are placing textboxes on top of an image, it will either move down or to the right of the image and this behaviour is the same in both SSRS 2005 and 2008.
jason,
ReplyDeleteThanks for your reply. I have 2 instances which are using same rdl file. one instance has report viewer pulling report from SSRS 2005 and other instance pulls from SSRS 2008. report that is pulled from SSRS 2005 looks good as how it should be. For the report pulled from 2008, text boxes and lables moved below the image. But when we print the report, it prints fine.
Thanks
Sri
Hi Sree,
ReplyDeleteI had sent a mail to your id asking for the rdl, hope you received it. Meanwhile, why dont you put the image as a background image and then use the text? I think this approach should work always
Jason,
ReplyDeleteI had sent an email to your gmail acnt u specifiedin the email.
Sri
Hi Sri,
ReplyDeleteI saw your report and the correct way of designing this should be having the VOID image as the background image of the report. If you would notice, you would get a warning when you preview this report in both SSRS 2005 and 2008 that overlapping report items are not supported. This is the reason why it gets moved.
It would be having the same functionality if the image is used as the background image of the report.
Jason,
ReplyDeleteJust wondering if you are still actively viewing this topic - I have an issue with a background image and multiple columns on a report.
Sure I am, would love to have your name and issues here
ReplyDeleteHi Jason, I am writing a SSRS blog as well. Please visit my blog and maybe we can link our blog together. http://ssrsdeveloper.blogspot.com/
ReplyDeleteThanks,
Chan
Does anyone know how to drilldown on a ssrs2008 Map, to diplay an image? (i.e. to display a .jpg file of a person)
ReplyDeletethanks for any help!
1) You need to make a report which will have a parameter for the persons name, and the report will display the photo based on the name parameter (something like given in this link - http://road-blogs.blogspot.com/2010/04/ssrs-reports-using-database-images.html)
ReplyDelete2) Then you need to have the map report, which will have a relation between the region name and the person name. Go to action, Go to Report and give the name of the report you created in step 1. Also pass the persons name as the parameter.
(the steps are given in this link - http://road-blogs.blogspot.com/2010/12/drill-down-in-ssrs-map-reports.html)
3) Now you should be having a drill down on ssrs 2008 map which will display the image of a person when clicked. You can use javasvript if you want the image report to be opened in a new window
Hello, thanks a lot for a detailed post. I did everything you mentioned and still couldn't get the image to display. The difference between your example and mine is that I have 2 datasets and only 1 dataset is attached to the tablix. However, the field based on which the image should display is in the other dataset. PID is the common field in both datasets and i get the value using on Lookup function. Can you please help? THanks!
ReplyDeleteIt is not possible to display an image using Lookup function (because it is not the field name that is returned, but the evaluated result which might be varbinary. This would throw up an error). Best way to go forward is to
ReplyDelete1) Join your 2 datasets into 1 using PID as the join condition
2) If you can't do the above, make the dataset with the image as the primary one, and lookup all the other fields (which would not be an image). This way you would not want to lookup an image.
Hi Jason,
ReplyDeleteI am using the image in my report which sends an email to my cilents ,when i click on image.I have used 'mailto:' for the same.
The problem, i face is,i want to include a hyperlink in the message text which should change based on the parameters that report use to filter the results. How can i do this? I tried using javascript:window.navigtaion but in vain.
Jason,
ReplyDeleteI learnt how to add image on report page. Yours only blog useful.
-Vinod Andani