Conditional Formatting

Hi to All,

in My  Table report, i would formatting my cell with a conditional formula,
then I create a Style with 2 condition   (over the Average, under the average)
and in the expression editor I insert   the formula [ new Boolean($F{field_1}>$V{avg_field_1}) ]

where $V{avg_field_1} is calculated as average of  field_1

but the cell is not colored, and I realized that the variable $V{avg_field_1}) is calculated only at the end of the table 

is possible that..??

thanks Max

mm972's picture
Joined: Jan 21 2015 - 2:58am
Last seen: 2 years 5 months ago

2 Answers:

Hi Max,


You can try to configure "Evaluation time" property for a text field within a Table cell. By default the evaluation time is set to Now, but you can change it to Band or Report. This will force the cell to be generated correspondingly at the end of Band or Report render time.


If this results into incorrect values being returned by table cells, then i can suggest to pre-calculate the $V{avg_field_1} variable using subreport. Subreports are being executed before the main report, so the idea here is that you will have the varialbe calcualted in subreport, return the value to the main report and then use this value in conditional expression. You can find detailed info in "17.3 Returning Values from a Subreport" section of iReport Ultimate Guide available under the Docs section:

Keep in mind that the conditional expression should be in a different band from subreport, otherwise it will be calculated before the variable is returned from subreport.


- Stas

stasp's picture
Joined: Jun 3 2009 - 9:53am
Last seen: 3 days 3 hours ago

Hi Stas,
I've tried how you explain me.
I have created a subReport and then I inserted the subreport in the main Report...
but I haven't the expected result....
in the subReport i have the sub_var1 , when I insert the the subreport in MainReport I map the sub_var1  with a variable  
created in MainReport main_var1
then to pass the main_var1 to the TableDataset, I create a Parameter and associate this Parameter  with main_var1 
but when I use this parameter in table or i use for create the consitional style for formatting the cell of the table
the value is ever NULL..
the subreport is in the TITLE BAND and the main report in DETAIL BAND , I've tried to change band but it was useless....
Can you give me a little help..

Thank Max



mm972's picture
Joined: Jan 21 2015 - 2:58am
Last seen: 2 years 5 months ago