Conditional formatting in a report
Conditional formatting means using expressions to determine how information is formatted. In its simplest form, and in most common examples, it is used in the color (and background color) properties. An example is using the following expression for the color property of a textbox:
=Iif(Me.Value > 0,"Blue","Red")
In this example, I'm using the Me
object, and Me
refers to the current textbox. Another example is this expression:
=Iif(Rownumber(Nothing) MOD 2,"PaleGreen","White")
If you use it for the background color property of a row then it means that the even rows will become pale green and odd rows will become white.
Note
Sometimes Me.Value
is not recognized in the expression builder. It will depend on if you use Report Builder or Visual Studio.
Let's use this now in a report. You can import the object: Packt - CH04-3 to follow the steps.
The dataset of the report is as follows:
I have used a matrix in the layout...