Jump to content
We've recently updated our Privacy Statement, available here ×

Need 2 create crosstab subreports under crosstab


goober100

Recommended Posts

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Figured it out; I was lead to believe that you could only insert subreports as type columnar or tabular, not as a crosstab subreport.  I was also lead to believe that you could only put crosstab reports in the "Summary" band.  What you need to do is set up the crosstab reports as seperate reports and embed them into a main report.  Here's what you can do:

Create 3 individual reports (.jasper files)

Report 1: Set up your main report to only pull the main values that you want to use to gather parameters to send to your subreport (that will contain it's own queries to pull all your sub-reporting data).

Report 2: Create a seperate report all together, remove all bands accept for 'Summary' Band.  Make sure that you add the parameters that you will need passed in from the main report in this report and that you put the parameters in the sql query (i.e. "where lname = $P{lname}").  In the summary band create and build the crosstab report that you want to show up as sub-reports in the main report.

Report 3: (This is if you wanted a "Summary" crosstab report representing all of the detail "subreport" crosstab reports).  Create a seperate report all together, remove all bands accept for 'Summary' Band.  In the summary band create and build the crosstab report that you want to show up as the Summary cross-tab report in the main report.  You would not use parameter values to build this report - you will put this report in the "title" band of the Report 1 and title section is seperate from queried data.

Inside of Report 1:

Drop and drag fields into the "Detail" band that you are using as parameters to pass to Report 2 (subreports).  Drag a "subreport" icon from the pallette into the Detail band.  Choose "Just Create The Subreport Element" and finish.  With the subreport active, in the properties window, go down to subreports area.  Here, you will populate the Subreport Expression field with the full name of the jasper report  that is the Report2 in quotes (i.e. "jaspersubreport.jasper").  In the Connection Type field, choose "Use a connection expression".  In the Connection Expression, use $P{REPORT_CONNECTION}.  Choose the "..." next to Parameters field.  Here, you need to add the parameters that will be passed in to your subreport from the main report.  Click "add" and enter the name of the field as the parameter name, and then for expression, you need to put the $F{lname} format to tell it to use the field from the main report.

If you wanted a Summary Crosstab report to show up one time before all the sub-reports, you drop and drag a subreport into the "Title" band of the main report.  Follow all the same procedures for setting up the sub-report properties, but you will not do anything with the parameters - since it is in the title section this report will need to be completely self sufficient.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...