Conditional Rows and Columns

Back from OOW and fighting a cold from all that 'sea level' air - give me the moutains any day. I dont really mean that - I lived by the ocean until we left the UK in '99 - I miss it, but standing atop Pikes Peak is a sight to behold. I promised normal service when I got back from crazy town, this morning there was a question on the forum asking how to achieve conditional rows and columns. I have admit I thought I had covered that here or in the documentation ... I can not find it so here goes.


Conditional Rows


This is pretty straightforward and later releases of the template builder will help you achieve even more easily. Basically you need an 'if' statement that will cover the complete row.


ConditionalRow1:


Notice the 'C' field, this contains the conditional code:


<?if@row:number(SAL)>2000?><?attribute@incontext:color;'red'?><?end if?>


see the '@row' thats going to apply the condition to the whole row for us. You can either hand code it or as I mentioned the template builder will do it for you. It provides a friendly dialog for simple conditions - if you have more complex requirements then you are going to have to get your feet wet or hands dirty in the code.


ConditionalRow:


The '@incontext' is a useful addition to the 5.6.3 release shortening code requirements further to update attributes, in this case the color.


The above condition will highlight the text red for the whole row where an employee has a salary greater than 2000.


ConditionalRow2:


Conditional Columns


This runs along similar lines to rows ie we have an '@column' command. Sadly the template builder cannot help you here ... yet. But the code is not tough to write. I have written something a little more interesting for the conditional column formatting. I have grouped the employees by department and then added some conditional logic to hide the Job column if the department name is 'Accounting'


ConditionalColumn:


Notice the 'CC' fields, I need one for the column header and the data cell, the contents are simple:


<?if@column:DNAME !='ACCOUNTING'?><?end if?>


 The @column defines the extent of the conditional statement ie just to the column, when executed we get the following:


ConditionalColumn2:


notice the missing Job column.


Now I have used some simple conditions you can of course get pretty complex in the logic, you're limited only by your imagination and your XSL knowledge, there by hangs a tale - you got questions get to the forum, Im there in Colorado mornings and late evenings. Get the template and data here.

Comments:

Can conditional formatting be done based on comparing two field values as opposed to comparing a field value against a number. Eg instead of 2000?> there is another field called MIN_SAL set to 2000 that can be at the same level or higher in the xml tree. I have tried =2000?> ..... which works but when I try =MIN_SAL?> ..... it displays all rows regardless of whether the SAL is greater than 2000 or not. Regards, BB.

Posted by Brian Batten on July 17, 2008 at 02:44 AM MDT #

Hi Brian You may need to clarify where the MIN_SAL is coming from. Assuming you are in a loop when showing the SAL value e.g. just using if:SAL > MIN_SAL is not enough - unless MIN_SAL is at the same level as SAL, which I doubt. You need to either use .//MIN_SAL to find the first instance of MIN_SAL frm the top of the tree or be specific /ROOT/MIN_SAL ie provide the complete path to the MIN_SAL value. You might also wrap number() around the values number(SAL) > number(/ROOT/MIN_SAL) this will force a numeric comparison rather than a string one or remove any hope that the XSLT engine will infer a numeric one. Tim

Posted by Tim on July 17, 2008 at 06:27 AM MDT #

I am promoting my blogs from one end to the other puticipatation in odd gossip forums and, unfortunately, most annotations or responses I am getting on these boards, not in a small-brained while in my blog refereements …

Posted by Robeplcq on February 16, 2009 at 11:39 PM MST #

Is there a way to maintain the table size constant even though we hide the column? In xsl fo, there is a attribute 'visibility' for fo:table-column, but I am unable to use it conditionally through BI-publisher. Appreciate your help in this regard

Posted by Nagashree on February 19, 2009 at 03:50 PM MST #

I tried the following directly from the manual lightgray It only works on PDF. Is there a restriction to the other formats (HTML, RTF)? Thank you in advance

Posted by Evris on May 21, 2009 at 02:22 AM MDT #

Sorry, something' gone missing from the code " lightgray"

Posted by Evris on May 21, 2009 at 02:25 AM MDT #

Thank you for the tip on conditional formatting. it did a great deal of help in catering for one of my BI Publisher reports

Posted by Sagar Junnu on September 13, 2009 at 11:15 PM MDT #

Hi I have some variables in my report, and depending upon variable values i would like to hide some columns. How can i find variable value in this .rtf template? Thanks & Regards ami

Posted by amitmah on November 02, 2009 at 01:39 PM MST #

I'm grateful for you because of this wonderful written content. You definitely did make my day :

Posted by never fail list building system on August 22, 2010 at 04:31 AM MDT #

Going to bed with a bottle of milk or juice is the most common cause.

Posted by Georgetta Rehling on September 25, 2010 at 07:58 PM MDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Follow bipublisher on Twitter Find Us on Facebook BI Publisher Youtube ChannelDiscussion Forum

Join our BI Publisher community to get the most and keep updated with the latest news, How-to, Solutions! Share your feedback and let us hear your voice @bipublisher on Twitter, on our official Facebook page, and Youtube!

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today