Jump to content

Row sum will not reset to zero for the next row.


Mark.Casey
Go to solution Solved by reportdev,

Recommended Posts

I have a subreport with rows containing four numeric fields and a variable that sums them up.  The variable is correct on the first row only.  On each subsequent row, it prints the cumulative total of all rows printed thus far.  How do I reset the variable so that it starts over and only totals the row it is on?  I have tried various combinations of settings, and nothing seems to do it.  (I am not a developer - just trying to fix a report via the variable Properties if possible.)

Jaspersoft Studio 6.2.1

 

Year

Sum

Figure 1

Figure 2

Figure 3

Figure 4

 

2017

$1,238,000

$700,000

$390,000

$98,000

$50,000

 

2018

$1,803,000

$250,000

$85,000

$70,000

$160,000

 

2019

$1,833,402.3

$21,149.43

$9,252.87

$0

$0

 

Thanks!

 

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Solution

On the Sum variable, the Increment type should be Column and the Reset Type should be Report

Check this report jrxml

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  --><!-- 2017-02-16T15:02:46 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="conditional" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="db6c00f0-db29-49f5-8e70-22e8b82b00ea">    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>    <queryString>        <![CDATA[select 2017as year,700000as figure1,390000 as figure2,98000 as figure3,50000 as figure4 from dual unionselect 2018as year,250000as figure1,85000 as figure2,70000 as figure3,160000 as figure4 from dual unionselect 2019as year,21149.43as figure1,9252.87 as figure2,0 as figure3,0 as figure4 from dual]]>    </queryString>    <field name="YEAR" class="java.math.BigDecimal"/>    <field name="FIGURE1" class="java.math.BigDecimal"/>    <field name="FIGURE2" class="java.math.BigDecimal"/>    <field name="FIGURE3" class="java.math.BigDecimal"/>    <field name="FIGURE4" class="java.math.BigDecimal"/>    <variable name="Sum" class="java.math.BigDecimal" incrementType="Column" calculation="Sum">        <variableExpression><![CDATA[$F{FIGURE1}.add($F{FIGURE2}).add($F{FIGURE3}).add($F{FIGURE4})]]></variableExpression>    </variable>    <background>        <band splitType="Stretch"/>    </background>    <columnHeader>        <band height="20" splitType="Stretch">            <staticText>                <reportElement x="0" y="0" width="80" height="20" uuid="46953091-95ae-45a0-824a-c6349193ff95"/>                <text><![CDATA[YEAR]]></text>            </staticText>            <staticText>                <reportElement x="180" y="0" width="100" height="20" uuid="c6dc70ef-2c28-4d64-9df8-c42816c01f31"/>                <text><![CDATA[FIGURE1]]></text>            </staticText>            <staticText>                <reportElement x="280" y="0" width="100" height="20" uuid="e9585303-7fe5-4507-a3c7-644f754e679f"/>                <text><![CDATA[FIGURE2]]></text>            </staticText>            <staticText>                <reportElement x="380" y="0" width="100" height="20" uuid="8239325a-b107-4454-81ed-e39d9514bb26"/>                <text><![CDATA[FIGURE3]]></text>            </staticText>            <staticText>                <reportElement x="480" y="0" width="100" height="20" uuid="e514dc9e-41e3-4d5b-945f-8075a4e15f55"/>                <text><![CDATA[FIGURE4]]></text>            </staticText>            <staticText>                <reportElement x="80" y="0" width="100" height="20" uuid="4f52ebc9-80bc-4db2-8dc5-50e49bb2ade5"/>                <text><![CDATA[sum]]></text>            </staticText>        </band>    </columnHeader>    <detail>        <band height="20" splitType="Stretch">            <textField>                <reportElement x="0" y="0" width="80" height="20" uuid="d50a5931-7d89-4975-a885-18f1449986e1"/>                <textFieldExpression><![CDATA[$F{YEAR}]]></textFieldExpression>            </textField>            <textField pattern="¤#,##0.##;¤-#,##0.00">                <reportElement x="180" y="0" width="100" height="20" uuid="3767ad7c-044a-48b2-85fe-884d4a721517"/>                <textFieldExpression><![CDATA[$F{FIGURE1}]]></textFieldExpression>            </textField>            <textField pattern="¤#,##0.##;¤-#,##0.00">                <reportElement x="280" y="0" width="100" height="20" uuid="949b7196-f620-4a45-a0a2-ebfc97016ae3"/>                <textFieldExpression><![CDATA[$F{FIGURE2}]]></textFieldExpression>            </textField>            <textField pattern="¤#,##0.##;¤-#,##0.00">                <reportElement x="380" y="0" width="100" height="20" uuid="bd1411b1-1326-43bb-a42c-ec8f91a30170"/>                <textFieldExpression><![CDATA[$F{FIGURE3}]]></textFieldExpression>            </textField>            <textField pattern="¤#,##0.##;¤-#,##0.00">                <reportElement x="480" y="0" width="100" height="20" uuid="304de87a-d1d9-4c65-82b1-20d3a5f54a06"/>                <textFieldExpression><![CDATA[$F{FIGURE4}]]></textFieldExpression>            </textField>            <textField pattern="¤#,##0.##;¤-#,##0.00">                <reportElement x="80" y="0" width="100" height="20" uuid="e8c5c029-32dd-47c6-8f6a-d623645f3f4c"/>                <textFieldExpression><![CDATA[$V{Sum}]]></textFieldExpression>            </textField>        </band>    </detail></jasperReport>[/code]

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...