Passing parameter to subreport chart dataset


I have a report with 5 subreports, 1 of them containing charts. Charts generated from datasets (there are 4 datasets and 8 charts), I want to pass my main report's parameter to charts in this subreport, how can that be done?

Also please confirm if this is the right way of doing, I have 5 different queries so created 4 subreports and a fifth for charts only with all 4 queries as datasets.

Thanks in advance!

follower's picture
Joined: Aug 5 2011 - 12:27am
Last seen: 6 years 12 months ago

3 Answers:

Passing main report parameters to subreport: left click on subreport and in the properties tab you will find a property named "Parameters". That is where you link the parameters. A better explaination is given here.

However can you give a better explaination of the second question? What I understand is that you have 5 queries but you are rerunning a few queries for the chart elsewhere in a subreport. Am I right?


kkriplani's picture
Joined: Sep 4 2015 - 2:18am
Last seen: 11 months 1 week ago

Hi, we can Achieve what you are looking for . I have also Did this before :-
Suppose A is main Report and B is Chart as Sub report
Step -1 :- create a1 as parameter with  same Class(java.lanag.Integer) in both A(main report) and B(Chart ass sub report)

Step-2 :- After you create the Dataset there you can see Parameter section there you can Copy paste the Parameter what you created for A(Main report)

Step-3 :-Drag and Drop the Sub report Component from Palette then when you click on Sub report right On the right side in your Jasper studio under Properties Tab open the Sub report and there will be Parameters button click on it and Add the Parameter name(a1) and Expression as($P{a1})

Step-4:- Save your report, and compile it .

When you run the Report A(Main report) then the Value which you give in a1 Parameter the same would be seent to B(Chart as Sub report) and it will be picked up by the Data set you have created in the Sub report.

Hope this Works.


santosh.audi19's picture
Joined: Sep 9 2015 - 9:58am
Last seen: 2 years 1 day ago


Thanks both for the response, I already passed main report parameter to my subreport, had problem with dataset parameter in chart which I resolved.


follower's picture
Joined: Aug 5 2011 - 12:27am
Last seen: 6 years 12 months ago