In this post, I will take you through the step by step procedure to create a Multi Select Parameter in Jaspersoft Studio.

This Method would just create a parameter Value where you have to Manually add multiple values which will then be passed on the SQL to fetch data. There will not be a value list appearing for this parameter. (If you want that functionality, it is possible only at the JasperServer level).

Lets Start.

1) Create Report with a simple SQL Query as Below.

MPImage01

2) Report Layout can be as per your specification. I have created it as below.

MPImage02

3) When I preview the Report It looks like this.

MPImage03

4) On the Outline section, Right Click on the Parameter section and select “Create Parameter”.
5) Name the Parameter as “P_COUNTRY” and select the Class as “Collection – java.util”
6) and Set is prompting to true by checking the check box.(By default it will be checked, so change it only when you need the parameter to be hidden.

MPImage04

7) Once the parameter is created, go to the Data Query section to edit the SQL Query to pass the Parameter Value. Use “$X{IN, v_name, MyParam}” code in the query as shown below.

MPImage05

8) Now when you preview the report, the report will ask you to provide the parameter value.

MPImage06

9) Select the browse button as shown in above figure (Button next to “No Elements”) and a window will pop up as below.

MPImage07

10) Click Add button and add your parameter Values. (Here the list will not populate as in Jaspersoft Studio there is no facility to generate this list. But if you publsih this report to Jaspersoft Server, we can create Multiselect Input Control and link it to P_COUNTRY parameter, there we can create a list value to appear for user selection.)

MPImage08

11) Now Click the Start Button below, to run the report.

MPImage09

12) And the Result will be the data related to your selection.

MPImage10

In my upcoming blog I will Publish this report to server and explain how to create Input control and Run the same report from server.