0

I'm using JasperReports with iReport to generate exports on my website.

Until now I successfully created many 'basic' reports with this format :

Title

Number | date | value

1 | 2014-08-10     | 42   `// with this part beeing programaticaly repeated`

2 | 2014-08-15 | 84

3  | 2014-09-05    | 24

What I need to do now, is to add a sum line for each months like this :

Title

Number | date | value

1 | 2014-08-10     | 42

2 | 2014-08-15 | 84

**SUM  | 2014-08 | 126**  `// I want to add this line at the end of every month`

3  | 2014-09-05    | 24

**SUM | 2014-09 | 24**

I haven't been able to find anything on internet because I don't know how to formulate my question. Everything I tried just add the 'sum column' after each basic column witch isn't what I'm trying to do.

Is there a functionality I missed or a trick to realize this ?

EDIT :

It isn't a Java but a JasperReports/iReport problem. Once I know how JasperReports allow to do it, I'll find how to do it in Java.

Alex K
  • 22,315
  • 19
  • 108
  • 236
Yabada
  • 1,728
  • 1
  • 15
  • 36
  • You can use grouping. [Data Grouping](http://jasperreports.sourceforge.net/sample.reference/jasper/index.html#groups) – Alex K Aug 13 '14 at 12:08
  • possible duplicate of [How to sum all values in a column in Jaspersoft iReport Designer?](http://stackoverflow.com/questions/13550514/how-to-sum-all-values-in-a-column-in-jaspersoft-ireport-designer) & [Grouping records in JasperReports](http://stackoverflow.com/q/14450634/876298) – Alex K Aug 13 '14 at 12:37

1 Answers1

1

There is a similar question here on SO that you can look at How to sum all values in a column in Jaspersoft iReport Designer? I have used this quick Google search to find more references.

You can also look at the demos that are provided with the Jasper Reports Project archive, for example: jasperreports-5.6.0/demo/samples/jasper/reports. There is also documentation on the JR web site that explain a bit more.

This should give a basic idea how to do the sum part. For doing it over the whole year's data and calculating the sum per month would require a grouping on the month which resets the variables every time the month of your date changes. This example might be overkill for what you want, more can be found with this search.

Community
  • 1
  • 1
nicoschl
  • 2,346
  • 1
  • 17
  • 17