Change the display based on a condition

Change the way your report displays depending on a condition in the RTL expression.

Note: This example is based on the ListDemo.4rp file in the OrderReport demo.
A condition in RTL uses the following syntax:
 Boolean-expression?expression-1:expression-2

For this example, the data source includes the field lineitemprice, and the field is a NUMERIC.

The report includes a Decimal Format Box that displays the line item price. You want the line item price to display red if below $100, and black if $100 or above. For the Color property, you enter the following expression:

lineitemprice<100?Color.RED:Color.BLACK

The Rating column for this report shows an Image Box displaying a "thumbs up" icon. You want this image to turn upside down if the line item price is below $100, turn to the right if the line item price is between $100 and $500, and display unturned if the line item price is $1000 or above. For the Layout Direction property, you enter the following expression:

lineitemprice<100?LayoutDirection.UpsideDown:lineitemprice<1000?LayoutDirection.TurnRight:LayoutDirection.Unturned

The report displays as in the following figure.

Figure: Stock Report

This figure shows the report with conditional values for the Line Item Price field and Rating image.