Monday 4 January 2010

SSRS - conditional formatting for lazy people

Let's say you create a report and you want to apply conditional formatting, in this case just a conditional colour of the font, there's a couple of ways to do this. Let's consider the below (mini) report.



We'll have to:
  1. Select the textbox containing the value =Fields!Revenue_KPI.Value
  2. Edit Color property to say =IIF(Fields!Revenue_KPI.Value<0,"Red","Black")
  3. Select the textbox containing the value =Fields!Volume_KPI.Value
  4. Edit Color property to say =IIF(=Fields!Volume_KPI.Value<0,"Red","Black")
If your table only contains two textboxes this is OK, but if your table has tens on textboxes this can be a lot of work, especially if you have footers containing totals.
The alternative is to use the value of the textbox instead of the value of the dataset field to determine if the color of the text needs to be red or black.
  1. Select all the textboxes you want to format
  2. Edit Color property to say =IIF(Me.Value<0,"Red","Black")
How easy is that?

No comments:

Post a Comment