I'm trying to build a SSRS report that shows player name and their photos (if there is any). How do I display a text e.g."No image" if image column return null value (or empty)?
I've tried to do this in SSRS report itself but no luck :
=IIF(IsNothing(Fields!PlayerImage.Value), "no image", Fields!PlayerImage.Value)
Any help is appreciated.
CodePudding user response:
Assuming you get the image from a database, add a "no image" image to your database and then return that in the dataset query.
For example, if you had two tables, One with a PlayerID and Names and another with PlayerID and Image. Then you could add an entry to the image table with an ID or, say -1 and an image that just contains some text or whatever you like. Then the query would be something like...
SELECT a.PlayerID, a.PlayerName
, ISNULL(i.PlayerImage, x.PlayerImage) AS PlayerImage
FROM myPlayerTable a
LEFT JOIN myImageTable i ON a.PlayerID = i.PlayerID
CROSS JOIN (SELECT * FROM myImageTable WHERE PlayerID = -99) x
No the report always has all the info it needs and it means you can easily change what you want to display such as an anonymous profile image that is often used.