I have a report and a subreport that basically prints this:
Here is the code for the main report:
You can specify a calculation type (like sum) when returning values from subreports. Therefore if you want to sum returned values for each group, you'll have to do something like this:
<variable name="returnSum" class="java.math.BigDecimal" calculation="System" resetType="Group" resetGroup="group"/>
...
<returnValue subreportVariable="return" toVariable="returnSum" calculation="Sum"/>