Using Multi-select parameter in Jasper

Parameters can be the filter conditions which can be applied in the data-visualizations. This bog gives steps wise description of creating a multi-select parameter while developing report.

There are 2 different types of Parameters
1. Single select
2. Multi-Select

creating Parameter in Jasper Studio:

For Example there are employees in a department and a report generates the employee details department-wise. If the user wants to view employees from more than 1 department user can create multi-select parameter in that case.

Following are steps to create a parameter

step1: In the outline to the left side of the jasper studio we can find parameters. Right-clcik and create a new parameter.for eg: lets create a parameter with name “dept” and in the class definition we must give “java.util.Collection”, we can also give default values it is optional.

Capture1

step2: In case we are using sub-report or the table component we need to pass the same paraeter with same name to the sub-report/table. In the above example we are using table. Click on table in the table component and in the properties pane select dataset table u will find the following

Capture2

step3: Then add the parameter from main report to the table/subreport.
and click on finish.
Capture3

step4: Using the parameter in the query. following is the syntax for using multi-select parameter in a query.

where $X{IN,d.department_id,dept}
Capture4

Thanks
Asha Bidiyasar

Leave a Reply