Often, it is useful to modify the format of data when a certain condition is true. This type of formatting is called conditional formatting. For example, you can display sales numbers in red if the value is below target, and in black if the value is above target.
You also can change the format of data in a column according to the values in another column. For example, in a report that shows customer names and the number of days each customer’s invoice is past due, you can highlight in blue any customer name that has an invoice past‑due value that is between 60 and 90 days. Then, you can highlight in red and bold any customer name that has an invoice past‑due value that is greater than 90 days.
Specifying a condition
To use conditional formatting, create a rule defining when and how to change the appearance of data. Only the data in columns supports conditional formatting. The condition part of a conditional formatting rule is an If expression that must evaluate to True. For example:
If the order total is less than 1000
If the customer credit limit is between 10000 and 20000
How to set conditional formats
1 Select and right‑click the column containing the data you want to format. Choose Format➛Conditional Formatting.
2 In Conditional Formatting, create a rule to specify:
The format to apply. Choose Format to select formatting options.
The condition that must be true to apply the format, for example, Profit Greater than or Equal to 2000.
Figure 6‑5 shows an example of a rule specified for a selected column, Profit.
Figure 6‑5 Conditional Formatting displaying a rule
3 Choose OK. Figure 6‑6 shows the conditional formatting applied to the report. In the Profit column, numbers greater than 2000 are displayed in bold. If the column contains aggregate data, aggregate values do not reflect the applied conditional formatting properties.
Figure 6‑6 A BIRT design displaying conditional formatting
Comparing to a literal value
The conditional expression shown in Figure 6‑7 compares each value in the Profit column to literal values that you type. Alternatively, you can select from a list of values from the Profit column. Selecting from a list of values is useful if the comparison value is a product name, and you do not know the exact product names, or if the comparison value is a date, and you do not know the date format to type. If the comparison value is a date, Report Studio also provides a calendar tool, which you can use to select a date.
Figure 6‑7 Defining a condition that uses the Between operator
How to select a comparison value from a list of values
1 In Conditional Formatting, below the field that takes a comparison value, choose Change Value.
2 In Value, select Specify literal value, and choose Select Values. The values in the selected column appear, as shown in Figure 6‑8. This example shows values in a profit column.
Figure 6‑8 Selecting a comparison value
3 If there are too many values in the list, you can type a string in Filter Text to search for values that begin with that string. For example, you can type 18 to view all profit values that begin with 18. You cannot search for strings that appear in the middle of a name.
4 Select a value from the list, then choose OK. The value appears in the comparison value field on Conditional Formatting.
Comparing to a value in another column
In a conditional expression, you can compare the values of one column with the values of another column. Figure 6‑9 shows a condition comparing the sale price value with the MSRP value. If the sale price value is greater, the product name appears in bold and underlined.
Figure 6‑9 Creating a rule that compares values in two columns
How to compare to a value in another column
1 In Conditional Formatting, choose Change Value.
2 In Value, select Use value from data field. A list of columns used in the report appears.
3 Select a column from the list, then choose OK. Conditional Formatting displays the column name in the comparison value field.
Figure 6‑10 shows the BIRT design with conditional formatting applied.
Figure 6‑10 A BIRT design with conditional formatting