Search code examples
reporting-servicessql-server-2022

Replace a Data Bar With an Image Based on Data Value


I have a requirement to produce a Scorecard in SSRS. The Scorecard has a column containing a Data Bar where the bar length indicates the severity of the issue on the scorecard line. When the severity of the issue is ZERO, the Data Bar should be replaced with an image (or icon) of a Green Star.

Scorecard Illustration

Is there a way to do this in SSRS?


Solution

  • You should be able to do this with a bit of lateral thinking. As you discovered you cannot overlap a data bar and another object as data bars occupy entire 'cells'.

    You could add another column and hide it based on the value you are checking but that would mean the star would be offset from the data bar and look ugly.

    So, what you can do is add another detail row to your table which is identical you the current row, on the second row, swap out the data bar for a star and then control the row visibility (which works way better than column visibility) based on the value.

    Here's a short GIF to show you it in action. In this example I have a simple table with an ID column and an Amount column. The star is shown only when the amount is <= 0.

    If it's too small to watch, right-click and open in new tab then you can maximise to see it.

    At first I just add a simple table to show the dataset contents, then add the data bar, additional row, Star etc.

    enter image description here