Wednesday, December 22, 2010

BI Publisher: Conditional Formatting


Conditional formatting can be used in the layout builder for various scenarios. Some of the scenario I could think of is,
1. Display/hide layout regions based on condition.
2. Display/hide boilerplate text based on condition.
3. Apply visual attributes based on condition.
4. Hide table row or column based on condition.

In the below paragraphs we will see how above scenarios can he achieved in BI Publisher.


When it comes to conditions, obviously its going to be an IF statement just like any other programming language. So here is the syntax of BI Publishers if statement,
<?if:condition?>
…..
<?end if?>


1. Display/hide layout regions based on condition.
By having the condition if and end if before and after the region can either display/hide a region in the template.

image
Same can be achieved using CHOOSE WHEN statement as below,
image
2. Display/hide boilerplate text based on condition.
By using inline if condition we can hide/display a boiler plate text. syntax of inline if statement is,
<?if@inline:condition?>
..
<?end if?>


image
Using inline if condition will avoid getting the hard next line. So that we will get the entire statement in one line or on the same line.

3. Apply visual attributes based on condition.

i) Place the cursor on the table cell on which you want to make the condition.
ii) Select Conditional Format from the BI Publisher toolbar/add Ins of word document.

image

iii) Select the field under the data field box,
image

iv) Enter the condition and click format button to format the text.
image

V) if you like to apply this visual attribute to the entire row, then select the checkbox “Apply to Entire Table Row”
image

Once you apply this conditional formatting you will get some codes getting added as,
<?if:number(SAL)>1000?>
<?attribute@incontext:color;'red'?>
<?end if?>


4. Hide table row or column based on condition.
To hide/display a row based on a condition we just need to add the condition at the beginning and end of the row as shown below,
image


To hide/display a column based on a condition we need @column with the if condition. Just like @inline we used earlier, user @column with the condition on the column you want to hide/display. Syntax,
<?if@column:conition?>
..
<?end if?>



Apart from the above explained if conditions, we have  if-then-else statement, syntax for this statement is,
<?xdofx:if element_condition then result else result2 end if?>


11 comments:

Michael Coughlin said...

Thanks this is very helpful.  But I am still having trouble with my template and xml

Tasneem said...

Hi,

Can we do Conditional Formatting in Charts in BI Publisher?

Ron Dijkstra said...

Great post thanx. Helped me a lot!

Guest said...

How do we use inline with xdoxslt?
For example:
This is not working:

Guest said...

""

Guest said...


Rahul said...

Pl. let me know how to calculate sum of conditional formatted column..

Kishor_shethia said...

Can I have conditional Image / logo in BI Publisher template / layout to reduce making new layouts just for different company logo in my group companies on JD Edwards OneWorld ERP. I think, I had such facility in Createfirms software which is a 3rd party tool to design documents from JDE pdf. 

Harishhaldar said...

I have three texts which i need to show on my report conditionally .i.e. if user selects section1, then he will get section1 text but if he selects section 1& 2, then he should get both the section text.Same for section 1,2 & 3.
Presently with "Choose" condition i can select only 1 section at a time but the same cannt be applied for multi select sections.
Thanks
Harishhaldar@gmail.com

Cézar said...

Hi, I need to know how to work this when I show only the records if the field value contains any string, for example show the records that in the field "Product" contain the "ABC" string. Please Help me with this. Thanks.

Chandradeep said...

This was really helpful. Thank you :)

Post a Comment