Monday 11 March 2013

Jaspersoft - Passing Parameter to Table's data source in iReport


Today, I was creating a report which include Table component. As per my requirement, I had to filter the report based on a Date column. Hence I had to pass the value of parameter from main report to Table’s data source. Finally I was able to achieve this by following below mentioned steps:

1. Create a parameter in the main report.

  • Right click on Parameters section in Report Inspector Pane and Select Add     Parameter.
  • Provide the Name of the Parameter. Lets give it REPORT_DATE.
  • In the Properties of the REPORT_DATE parameter, change the Parameter class to   java.util.Date.

Now we have create a Parameter in the Main Report. Its time to pass the value of this parameter to Table’s Source Dataset. To pass the value, we need to create a parameter in the Table data-set as well.

2. Expand the Table’s data-set in the Report Inspector Pane.

  • Right click on Parameters and Select Add Parameter.
  • Provide the Name of the Parameter. Lets give it TABLE_REPORT_DATE.
  • In the Properties of the TABLE_REPORT_DATE parameter, change the Parameter class to  java.util.Date.

Now, we have created a Parameter in the Table dataset as well. its time to Pass the Value of a parameter to Table Data-set.


3. Right Click your Table Dataset.

  • Select Edit Table data source.
  • Select Parameters Tab and Click on Add button to add the parameter.

  • From the Dataset parameter name , Select the parameter that we have created in Step 2. (TABLE_REPORT_DATE).
  • In the expression box, Provide the value of the parameter of the main report parameter. $P{REPORT_DATE}. This will pass the value of REPORT_DATE parameter from the main report to Table dataset parameter TABLE_REPORT_DATE.    


Now, you can utilize the value of the parameter in the Table dataset as per your requirements. You can use this parameter in the where clause of the Table dataset query etc.

Now, when you will run the report, Parameter REPORT_DATE (Defined in the score of Main Report) will be prompted and then its value will be passed to TABLE_REPORT_DATE parameter defined in the scope of table data set.

1 comment:

  1. Fine method of telling, and enjoyable article to acquire factual statements.
    this post

    ReplyDelete