• Post category:BI Publisher
  • Post comments:0 Comments
  • Post last modified:August 7, 2020
  • Reading time:3 mins read
How to use IF IF-ELSE OR AND conditions in RTF template BI Publisher
How to use IF IF-ELSE OR AND conditions in RTF template BI Publisher
- How to use IF IF-ELSE OR AND conditions in RTF template BI Publisher
Total Visits: 41
Todays Visits: 0

In this article we will look into different ways of writing the IF condition in RTF template to achieve complex requirements.

Every BIP or HCM Extract will have a template tagged to them to get the output in different formats.. RTF is the most common template to get the output in PDF/HTML/Excel.

If there is a requirement to write conditional logic in RTF template, then IF condition can be used in such cases. Mostly in case of letters (Offer Letter/Appraisal Letter) to conditionally skip/display some paragraphs and also in regular templates when there are condition based calculations.

Method 1:

Use If statement directly in the template as Text or form field

<?if:FLAG_1=’Y’?> Yes <?end if?>

Method 2:

Use If else statements using xdofx command

<?xdofx:if SALARY > 10000 then 'Salary More than 10K' else 'Salary less than 10K' end if?> 

Method 3:

Nested If Sample using xdofx


Method 4:

If else condition using xdoxslt


Sample to display different field value based on a field value

<?xdoxslt:ifelse(BASE_NAME = 'HOURS',VALUE,CAL_VALUE)?>

Method 5:

Use choose statement if there are multiple conditions

<?when: COMPANY=111?>Legal Entity 1<?end when?>
<?when: COMPANY=222?>Legal Entity 2<?end when?>
<?when: COMPANY=333?>Legal Entity 3<?end when?>
<?otherwise?>Legal Entity 4<?end otherwise?>
<?end choose?>

Using OR and AND conditions in the IF statement:

We have to be very careful with the syntax of the statement that we write when we use the OR and AND commands as they don’t work if we don’t follow the proper syntax


<?if:XMLfield=value1 or XMLfield=value2?> display Calue <?end if?>


<?if:(sum(VALUE)=0 or sum(AMOUNT)=0)?>0<?end if?>

We need to enclose the total condition in braces ( and ).

The operators or & and should be in lower case only else they won’t work properly.

If there are multiple conditions based on which some text needs to be shown it can be written as below using and & or conditions.

<?if:((MEMBER='N' and SALARY_BASIS_CODE='HOURLY') and (ASG_CAT='Full-time' or ASG_CAT='Part-time') and (CITY='Las Vegas' or CITY ='Laughlin'))?>

Note: Make sure you use braces for the entire condition & ensure that or & and are used in lower case to make the condition work perfectly.

Hope this is useful. You can use any of the above methods depending on your requirement.