View Report:  Demo Report – Allow Multiple Values in your Report Parameter

Creating a parameter in BIRT that allows multiple values is easy with JavaScript

Download Report: BIRT Report Parameter Allow Multiple Values using JavaScript (348 downloads)

If you want your BIRT report to allow multiple values, you can do so with a little JavaScript.

The key component is javaScript in the “beforeOpen” event of the DataSet.


  • 1. Create a Data Set

    Create a Data Set.  Call it “Orders_by_Country”.  Using SQL code, write a query to extract the total number of orders from each country countries of the “CUSTOMERS” table in the “ClassicModels Sample Database”.
  • 2. Create a 2nd Data Set

    You will use this for your report parameter(that you will set up in step 3).  Call it “Country_List.  You want to make a list showing every country available based on the customers list.  Use “GROUP BY so that countries in the list are unique.  You can use “UNION” so that you can allow the user to select “ALL” the countries without having to click every country.
  • 3. Create a report parameter

    Create a report parameter, “rp_Countries”. Set the Data Type to “String”.  Select “Dynamic” radio button from “Select List Values”.  You could do this using a static list too.  We are using dynamic here…so select “Country_List” from the Data Set drop down menu.  Be sure that the checkbox “Is Required” is selected.  Select “COUNTRY” from the “Select Value Column” drop down menu.   Select “COUNTRY” from the “Display Text” drop down menu.  Be sure to check the checkbox labeled “Allow Multiple Values”.  When it’s all done, click “OK”.
  • 4. Make Table

    Drag and Drop the Data Set “Orders_by_Country” onto the Layout Editor. You can improve the appearance as you like or leave it as is.
  • 5. Add Script

    The last step is to select the Data Set “Orders_by_Country” and click on the script tab. This will open a Script Editor.  There are 5 events that fire for this Data Set.  Click on Script Event dropdown menu on the top left side of the script editor.  Select “beforeOpen”.  Now insert the following code:
    Code Snippet
    if(params["rp_Countries"].value[0] != "All") { this.queryText = this.queryText.replace("1 = 1", "COUNTRY IN('" + params["rp_Countries"].value.join("','") + "')"); }
      Preview/Run the Report.