In Jaspersoft iReport Designer, you can define a parameter that will be retrieved by a dialog box when a report is previewed. This parameter can be used to restrict the result set -- like added to a WHERE clause -- and that result set can saved off along with the report.
The first part of the operation is to add the parameter. Right mouse click on the Parameters node in the Report Inspector docker and select "Add Parameter". Go to Window> Report Inspector if the docker isn't showing.
|Parameters Node in Report Inspector Docker|
|Parameter in Properties Docker|
|Report Query Button|
When the Report Query is displayed, edit the SQL to receive the parameter: "WHERE dy.year_nb =". Then drag the parameter from the Available Parameters box onto the query.
|Add Parameter to Query|
Previewing this example will now display a prompt (if configured as such in the parameter Properties docker). This prompt retrieves a parameter value and uses it to form a result set. I can run the report repeatedly, exporting the results as HTML and PDF.