2
votes

is it possible to have a sum in detail band in iReport? It is important to have cells merged vertically after export to excel like this:

-----------------------------
| id  | year | value | sum  |
-----------------------------
|     | 2010 |  55   |      |
|  1  | 2011 |  65   |  180 |
|     | 2012 |  60   |      |
-----------------------------
|  2  | 2010 |  70   |  70  |
-----------------------------

My idea is to have the main query with GROUP BY clause and for "year" and "value" use table component with another query. Problem is that my query is long running and i need to have only one in whole report.

1
Do the cells absolutely need to be merged, or are you just looking for a way to sum in the detail band and show that once per group?Lisa
I need to have the cells merged and values centered after export to excel.martinnemec3

1 Answers

3
votes

First have a look at here. It's about grouping rows.
You will see that you should create a group in your report, not in the query depending on your id field.

  1. For calculating the sum field, drag the value field to the column footer, and then you will see a pop-up menu. Click to the result of an aggregation function radio button, then choose sum function. This will create a variable to calculate the sum of the value field. Change this variable's reset type to group (to id_group). Use this field in your sum field.
  2. For grouping rows depending on id, click on the sum field and set this field's print when group changes to id_group.

this should help :)

when you group your fields your table will look like this. The grouped fields are at the top.

-----------------------------
| id  | year | value | sum  |
-----------------------------
|  1  | 2010 |  55   |  180 |
|     | 2011 |  65   |      |
|     | 2012 |  60   |      |
-----------------------------
|  2  | 2010 |  70   |  70  |
-----------------------------