Time for action – styles with formulas
We will configure the rectangle's Style.bg-color property, which we have previously placed in the Details section, so that its color will be defined based on a row-by-row evaluation of the sum_amount field. We will use the formula editor and the IF
function to do so. Next, we will create two parameters so that the final user can establish the conditions based on which the rectangle will be colored. What we will do now is create a formula so that the background color of the rectangle we added earlier changes according to certain values.
- We select Rectangle, and in the Style tab, press the button found on the right of bg-color:
This will open the formula editor. In Formula:, we type the following:
=IF([sum_amount]<4;"#990000";IF([sum_amount]<6;"#cccc00";"#66cc00"))
Next, we click on OK to continue.
We will explain each part of this calculation, but first we will talk a bit about the function IF. The IF
function receives the following three parameters...