Pages

Thursday, January 16, 2014

How to conditionally hide the column in pentaho report designer

The requirement is to hide a column and it's label if data in that column is null.

Contional hide of report element:-
To hide report elements based on certain conditions, we can define a formula under 'Style' -> 'visible'.
One interesting use case is to hide the labels of the report if no data is returned.
For example, to hide all labels of the report if the field 'field1' has a null value:
  • Add a sub-band on the report and insert the labels that you want to hide in the sub-band. Thus we will not have to define the same formula for each label, but rather only for the sub-band.
  • Highlight the sub-band and go to 'Style' -> 'visible' properties.
  • Add the following formula
    =IF(ISNA([field1]);"False";"True")
We could also hide the report elements based on whether we have entered a value for a user parameter or not.

  • Highlight the report element and go to 'Style' -> 'visible' properties
  • Enter the below formula
    =IF(LEN([param1])=0;"False"; "True")
    where param1 is the parameter name.

No comments:

Post a Comment