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

How to list group counts


citress

Recommended Posts

Hi, I have defined a Group in my report and also a variable that contains the count per group.

I would like to display a simple table that displays the grouping expression in the columns and the count for the group in the row below. So my table simply has columns that represent each element in a group, and a single row that contains the count of the items in that group.

How do I do that? I tried using a table but had trouble defining the datasource expression since the rows are coming from a user-defined variable.

Or is there another way to present the information I'd like to show, other than a chart (since I'll have a similar more detailed chart operating on the same dataset and the table is more like a summary)?

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

 

Hi,

What you are doing effectively is designing a summary report in the form of a table, which does not show the actual data, but a summary of the data (just counts of records). I guess you are trying to use the Detail1 section of iReport designer (or the <detail> JRXML tag) to show the only row of your report, which is giving you trouble.

For your application, the <detail> tag should not contain anything (except perhaps an empty <band> child tag) and therefore the Detail1 section should remain empty for this summary report.

You will write your grouping expressions in the Column Header section of iReport designer (or the <columnHeader> JRXML tag).

You also perhaps don’t need to define the group count variable. You just need to drop the field for which you defined the group into the group header section (the <groupHeader> child of your <group> JRXML tag). If you are using iReport, it will automatically detect that you are dropping something that has many values into a group header section, which is unusual. So iReport will show you a dialog asking what kind of value you want to display. From that dialog, you will select the count aggregation function. And that’s it, hopefully.

If you have multiple groups with different expressions, you will drop all the fields or variables associated with those groups into the same group header. I think you will not need to use all the group header sections.

Try this and post your findings. If you still face problem, better post your JRXML.

Cheers,

bsiddiqui

Author, JasperReports 3.6 Development Cookbook

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...