February2021 1DevelopingReportsWithConditionalData
February2021 1DevelopingReportsWithConditionalData
Using the sample RTF design template and XML data set from the Filtering Data Tech
Tip.
These tech tips are offered free of charge in the spirit of sharing knowledge with others. They do not include technical support, should you have a problem with them. We are always interested in how they can be improved, please do not hesitate to email us your comments. These tips have
been thoroughly tested by our consultants in a variety of environments. Please read these tech tips thoroughly and be sure that you understand them before trying to use them. We can not be responsible for issues that develop because of the configuration of your hardware, technical
environment or application of the tech memos. If you are not sure, then we urge you to contact Oracle technical support or your local support consultant for assistance.
DEVELOPING REPORTS WITH CONDITIONAL DATA
BI Publisher Add-On allows the hiding of a specific area based on a condition. This
example highlights the steps to do this for either a Table Cell or Row.
Place the cursor just before the Status placeholder and click Conditional Region in the
BI Publisher ribbon. This example will display the Status value only if it matches (Equal to)
‘Quote_Received’. Enter the condition information in the BI Properties window. Note the
different Data Field pulldown options. Since the operator required is for a character
pattern, only ‘Equal To’ and ‘Not Equal To’ are feasible options.
The Conditional Region placeholder C is inserted where the cursor was placed but the
placeholder EC is inserted in the next cell. This needs to be moved to the right of the
Status placeholder.
DRMcNATTY Page 2
DEVELOPING REPORTS WITH CONDITIONAL DATA
Using the Field Browser for each placeholder would display the following code. The IF
condition acts on the Status values.
Placeholder C: <?if:STATUS='Quote_Received'?>
Placeholder EC: <?end if?>
Click PDF in the BI Publisher ribbon to preview the output. Based on the Conditional
Region only Status of ‘Quote_Received’ are displayed.
DRMcNATTY Page 3
DEVELOPING REPORTS WITH CONDITIONAL DATA
Using the operator AND means all conditions must be satisfied. Expanding on the
original example, the IF condition will include the Vendor ID must also be ‘CPM’.
The output now displays Status of only Quote_Received where the Vendor ID is ‘CMP’.
DRMcNATTY Page 4
DEVELOPING REPORTS WITH CONDITIONAL DATA
This example highlights the steps on a row using the placeholders from the original
example.
Placeholder C: <?if:STATUS='Quote_Received'?>
Placeholder EC: <?end if?>
The Amount Total is not affected by the IF condition and must be modified. Highlight
the Total placeholder and display the code using the Field Browser. The current code
sum(AMOUNT) is the sum of all the records. Filtering code must be added at the parent
level. After AMOUNT the code [../STATUS='Quote_Received'] is included. This replicates
the IF Condition but applied for all records (parent level) in the XML data set.
DRMcNATTY Page 5
DEVELOPING REPORTS WITH CONDITIONAL DATA
Using the original Tech Tip RTF template, place the cursor just before the Status
placeholder and click Conditional Format in the BI Publisher ribbon. Select the ‘Status’
Data Field with type ‘Date/Text’ and in Condition 1 select the operator ‘Equal to’
‘Quote_Received’ in the corresponding field. Check the ‘Apply to Entire Table Row’
DRMcNATTY Page 6
DEVELOPING REPORTS WITH CONDITIONAL DATA
Click the Format button and check the Background Color and select the color red.
Similarly check the Font Color and select the color white. Click OK.
In this instance there is no separate ‘end if’ tag as this is included in the code for the C
placeholder.
Opening the C placeholder with the Field Browser the ‘end if’ is at the end. This is
because the code is specified for in context (within the cell). It would affect whichever
cell this placeholder is inserted. With the ‘Apply to Entire Table Row’ checked, the code
@row extends the in context to all cells in the row.
DRMcNATTY Page 7
DEVELOPING REPORTS WITH CONDITIONAL DATA
Placeholder C:
<?if@row:STATUS='Quote_Received'?>
<?attribute@incontext:background-color;'Red'?>
<?attribute@incontext:color;'White'?>
<?end if?>
Multiple conditions can be set (see Condition 2 section). By default, the properties
window provides up to two conditions but more could be added to the code. The
additional condition added is Background of Green and font color white if Status is
‘NTP_Acknowledged’.
DRMcNATTY Page 8
DEVELOPING REPORTS WITH CONDITIONAL DATA
It can be seen from the code the conditions are working independently of each other.
Each one is its own in context formatting IF condition.
Placeholder C:
<?if@row:STATUS='Quote_Received'?>
<?attribute@incontext:background-color;'Red'?>
<?attribute@incontext:color;'White'?>
<?end if?>
<?if@row:STATUS='NTP_Acknowledged'?>
<?attribute@incontext:background-color;'Green'?>
<?attribute@incontext:color;'White'?>
<?end if?>
DRMcNATTY Page 9
DEVELOPING REPORTS WITH CONDITIONAL DATA
This option uses the extended XSL and SQL functions (xdofx) provided by BI Publisher.
Use the Field Browser on the selected STATUS placeholder to edit the code in place.
The code to insert combines IF THEN ELSE function with the AND operator.
With this example if the STATUS is equal to 'Quote_Received' AND VENDOR_ID equals
'CPM' then display ‘Received from CMP’ otherwise display the returned value from
Status. Click Update after insertion.
Code to insert:
<?xdofx:if STATUS = 'Quote_Received' and VENDOR_ID = 'CPM'
then 'Received from CMP'
else STATUS
end if?>
* Note the syntax is case-sensitive.
DRMcNATTY Page 10
DEVELOPING REPORTS WITH CONDITIONAL DATA
In summary, this Tech Tip provided some different conditional options to use, whether by
hiding, formatting or affecting what is displayed. The flexibility they provide assists in
satisfying many client specific reporting requirements.
DRMcNATTY Page 11