I am using iReport 3.6.2 to build reports. I need to build a report that displays the total of each package. My sql query returns the below results.
**PackName---------PackCount**
pack1 -------------- 4
pack2 -------------- 3
pack1 -------------- 1
pack3 -------------- 3
pack2 -------------- 3
pack1 -------------- 2
My report needs to group the PackName and add the related PackCount like the below example
**Package Name ------------ Total**
pack1 ---------------------- 7
pack2 ---------------------- 6
pack3 ---------------------- 3
I've got my groupingCode as below
<variable name="PacksCountSum" class="java.lang.Integer" incrementType="Group" incrementGroup="packsGroup" calculation="Sum">
<variableExpression><![CDATA[$F{packCount}]]></variableExpression>
</variable>
<group name="packsGroup">
<groupExpression><![CDATA[$F{packName}]]></groupExpression>
<groupHeader>
<band height="20">
<textField>
<reportElement mode="Opaque" x="0" y="5" width="515" height="15" backcolor="#C0C0C0"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{packName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="460" y="1" width="30" height="15"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PacksCountSum}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</group>
But my results is being displayed as below
**Package Name ------------ Total**
pack2 ---------------------- null
pack1 ---------------------- 3
pack2 ---------------------- 8
pack3 ---------------------- 10
Could any one please assist me and guide me in the right direction. I cannot seem to find where my mistake is.