Search code examples
jasper-reports

Ireports with multiple filters


I'm designing a report on Ireport with a SQL query, and I'm working with filters, basically I want to be able to compare a input parameter "shift" with a field in my report, so I can show my report by shift.

This part of the report works fine, I just used a filtering expression $F{Shift}.equals( $P{shift} ), however this only works with one shift, but I want to also be able to see all shifts in the same report. Is there a way to do this?

As @Pu297 suggested, I could use an IN comparation in my SQL query, but setting it like this:

SELECT * FROM foo WHERE shift IN P!{shift}

Where my shift ireport parameter is a String and I type it in the way "1,2,3" to show the first 3 shifts


Solution

  • Your SQl Query

    SELECT * FROM foo WHERE shift IN ($P!{shift})
    

    And your input text should be

    '1','2','3'