How to create a sum variable in ireport dataset for table?

757 views Asked by At

I create report with table component , for the table I create a dataset and it displays a table correctly. my outer report query is just select 1 and query for inner table's dataset is select * from hlatlng

So the result of query gives me 4 fields I want to display sum of one field(tickets) at the end of the table.

Here is the fields and variables,

<field name="rtime" class="java.sql.Time">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="speed" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="tickets" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="pasangers" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <variable name="ticketSum" class="java.lang.Integer" calculation="Sum">
        <variableExpression><![CDATA[$F{tickets}]]></variableExpression>
    </variable>

and placed it as

<jr:columnFooter style="table 1_CH" height="31" rowSpan="1">
                        <textField>
                            <reportElement x="0" y="0" width="90" height="31" uuid="ac47cab6-8e25-4436-a2cc-4973a0d95142"/>
                            <textFieldExpression><![CDATA[$V{ticketSum}]]></textFieldExpression>
                        </textField>
</jr:columnFooter>

the variableExpresion I gave here is ,

Integer.parseInt($F{tickets})

Can anyone explain me where I am going wrong?

0

There are 0 answers