Changing Properties Based on Value of Field

Cory Fifield -

 

In order to change a labels color based on the value associated with it, we need to use Expressions. Each label has multiple properties that can be modified based on expressions. These Expressions are set at the specific property level. 

 

Example: I want to change a border on my label based on a value. I would need to edit the Expression for Border Color and then create an expression that defines what conditions to look for and what colors to set based on those conditions.

 

Border Color Expression:

mceclip0.png

 

Border Color Expression Editor:

mceclip1.png

 

 

Steps To Set Label Color Using Expression

1. Click on a Label in the Detail Band

mceclip2.png

 

2. Find the property you wish to change based on the value and click the button on the right of the property to open the X Expression Editor. For this example the Font Color (Foreground Color) will be set based on the value.

mceclip3.png

 

3. Create a logical expression that will set the colors based on certain conditions. In the following expression, we check to see if the discount percent is greater than or equal to 15, if this condition is true the text will be Green. If the condition is false the text will be red.

Expression: Iif((([DiscountAmount] / [TotalCost]) * 100) >= 15,'Green' ,'Red')

mceclip4.png

 

Example Output:

mceclip6.png

 

 

Have more questions? Submit a request

Comments