Sum previous with current column

1

Hi, I have a table in my ad hoc view that look like this

Oct Nov Dec Jan
3 5 0 4

Is it possible to sum previous with current column like this?

Oct Nov Dec Jan
3 8 8 12

 

alexander.backlund's picture
Joined: Sep 21 2015 - 11:42pm
Last seen: 2 years 9 months ago

Hi,

there are two options of doing this.

1.) you can write your query like this

select oct as oct ,(oct+nov) as nov,(oct+nov+decm) as decm from Table_name;
 

2.) If you want to do in jasper you have to edit the exp of text fields. i am giving the XML code of detail section of my report.

you can refer to that.(Same exp that you are putting in the query you can put in text fields)

 

 

<detail>
        <band height="125" splitType="Stretch">
            <textField isStretchWithOverflow="true">
                <reportElement x="0" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{OCT}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement x="100" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{OCT}+$F{NOV}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement x="200" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{OCT}+$F{NOV}+$F{DEC}]]></textFieldExpression>
            </textField>
        </band>
    </detail>

ankit830 - 3 years 11 months ago

0 Answers:

No answers yet
Feedback