0% found this document useful (0 votes)
14 views

February2021 1DevelopingReportsWithConditionalData

This document outlines three methods for adding conditional logic to reports in Oracle BI Publisher: 1. Conditional regions allow hiding portions of a report based on conditions like only showing a cell if a field matches a value. 2. Conditional formatting applies formatting changes like font colors conditionally, such as making rows red if a field equals a value. 3. IF/THEN/ELSE functions let reports display different text depending on conditional logic, like showing "Received from CMP" if two fields match.

Uploaded by

dbmanhero
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

February2021 1DevelopingReportsWithConditionalData

This document outlines three methods for adding conditional logic to reports in Oracle BI Publisher: 1. Conditional regions allow hiding portions of a report based on conditions like only showing a cell if a field matches a value. 2. Conditional formatting applies formatting changes like font colors conditionally, such as making rows red if a field equals a value. 3. IF/THEN/ELSE functions let reports display different text depending on conditional logic, like showing "Received from CMP" if two fields match.

Uploaded by

dbmanhero
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

DEVELOPING REPORTS WITH CONDITIONAL DATA

ORACLE PRIMAVERA UNIFIER & BI PUBLISHER

This Tech Tip will outline conditional methods to developing reports.

Conditional methods include:


1. BI Publisher: Conditional Region
2. BI Publisher: Conditional Format
3. Using IF THEN ELSE

Using the sample RTF design template and XML data set from the Filtering Data Tech
Tip.

For Each DS record loop:


Placeholder F: <?for-each:DS?><?sort:RECORD_NO;'ascending';data-type='text'?>
Placeholder E: <?end for-each?>

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

This is the data when previewed.

1. BI Publisher: Conditional Region for a Table Cell or Row

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.

Including multiple conditions.

Using the operator OR allows one of multiple conditions to be satisfied. Expanding on


the previous example, the IF condition will include if the Status is also
‘NTP_Acknowledged’.

The code now includes this.


<?if:STATUS='Quote_Received' or STATUS='NTP_Acknowledged'?>
* Note the syntax is case-sensitive.

DRMcNATTY Page 3
DEVELOPING REPORTS WITH CONDITIONAL DATA

The output now displays either Status of Quote_Received or NTP_Acknowledged.

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 code now includes this.


<?if:STATUS='Quote_Received' and VENDOR_ID='CPM'?>
* Note the syntax is case-sensitive.

The output now displays Status of only Quote_Received where the Vendor ID is ‘CMP’.

Conditional Region on a Row

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?>

Move C between the record loop (F)/Project No placeholders and EC between


Amount/end of loop (E) placeholders. Doing this ensures the IF condition is applied to
the row rather than a specific cell in a row. The Conditional Region placeholders could
be inserted anywhere between the record loop. However logically the placements
should encompass all cells in the row.

Now only records with the Status of ‘Quote_Received’ are displayed.

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

The Total Amount is now corrected.

2. BI Publisher: Conditional Format

Conditional Format is similar to Conditional Region except it allows for a formatting


change based on a condition. This example will set the row background to red and
font color to white for records where Status is equal to ‘Quote_Received’.

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?>

Previewing would generate the following output.

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

3. Using IF THEN ELSE

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

Previewing would generate the following output.

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

You might also like