In the jrxml, I want to be able to get TOTAL and AVERAGE of a large number of columns easily without explicitly writing variables for each of the columns like I have done for one of the columns in my report, as referred from this link. Any reference or a sample would be highly appreciated.
<variable name="total_unit1_kwh" class="java.lang.Double" calculation="Sum">
<variableExpression><![CDATA[ $F{unit1_kwh} ]]></variableExpression>
</variable>
And, in summary,
<summary>
<band height="32">
<staticText>
<reportElement x="0" y="0" width="40" height="16"/>
<box bottomBorder="Thin" leftBorder="Thin" rightBorder="Thin" padding="2"/>
<textElement textAlignment="Center">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Total]]></text>
</staticText>
<staticText>
<reportElement x="0" y="16" width="40" height="16"/>
<box bottomBorder="Thin" leftBorder="Thin" rightBorder="Thin" padding="2"/>
<textElement textAlignment="Center">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Avg]]></text>
</staticText>
<textField pattern="#0.0">
<reportElement x="40" y="0" width="50" height="16"/>
<box bottomBorder="Thin" rightBorder="Thin" padding="2"/>
<textElement textAlignment="Center">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{total_unit1_kwh}]]></textFieldExpression>
</textField>
</summary>
The following image is to show the columns of which I need to get total and average.