Search code examples
jasper-reports

Hide Records based on field values


we are currently using iReport, we have a requirement to only display records on a report with discrepancies between fields. To complete this report I will need to hide records that have matching values in two fields. As far as I am aware I can use a print when expression but this is only to hide fields alone not entire records. What would be the process to do this?

I have a boolean created within iReports with the following Expression:

$F{Value1}.equals($F{Value2})

I need to use a print when Expression tag to NOT display the record if this boolean is true.

I've tried looking at the reverse

if(!$F{Value1}.equals($F{Value2})) but iReport doesn't seem to like that.


Solution

  • Try adding a ! before the expression like this:

    !$F{Value1}.equals($F{Value2})
    

    This says: Don't print when the Value1 equals Value2, which I think is what you want.

    Your second expression with "if" in it does not work, because it's not a valid boolean expression. An if statement is a control structure and does not have a return value.