Conditionally Formatting a StyleSheet

You can conditionally format report components, display a graphic, and include links in your report based on the values in your report. Using conditional styling, you can:

To conditionally format reports, add the WHEN attribute to a StyleSheet declaration. The WHEN attribute specifies a condition that is evaluated for each instance of a report component (that is, for each cell of a tabular report column, each element in a chart, or each free-form report page). The StyleSheet declaration is applied to each instance that satisfies the condition, and is ignored by each instance that fails to satisfy the condition.

To conditionally format reports, using the WHEN attribute, the format is:

TYPE=type, [subtype,] attributes, WHEN=field1 relation_operator
{field2|value},$

Issue the following request:

TABLE FILE EMPLOYEE
HEADING
" "
"Employee"
" "
"Salary Report 2018"
" "
"Page <TABPAGENO"
" "
SUM CURR_SAL AS 'Current,Salary'
BY DEPARTMENT BY LAST_NAME BY FIRST_NAME 
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF, UNITS=INCHES, $
TYPE=DATA, FONT='TIMES', $
TYPE=DATA, COLOR=RED, STYLE=BOLD + ITALIC,
WHEN=CURR_SAL LT 10000, $
TYPE=DATA, COLUMN=CURR_SAL, BACKCOLOR=AQUA, COLOR=NAVY, STYLE=BOLD,
WHEN=CURR_SAL GT 10000, $
TYPE=TITLE, FONT='HELVETICA', $
TYPE=HEADING, FONT='HELVETICA', STYLE=BOLD, SIZE=14, JUSTIFY=CENTER,
COLOR=WHITE, BACKCOLOR=DARK TURQUOISE, $
TYPE=HEADING, LINE=6, BACKCOLOR=WHITE, COLOR=DARK TURQUOISE, $
TYPE=HEADING, LINE=7, BACKCOLOR=WHITE, $
ENDSTYLE
END

Run the request. The output is:

Notice that employees with salaries less than $10,000 are red and italic and employees with salaries greater than $10,000 are navy and bold, with a dark turquoise background.

WebFOCUS

Feedback