I have one variable:
BigDecimal
Calculation = Sum
Rest Type = report
Variable Expression = $F{Potentials_Netto_Winst}
This variable gives me a sum of all the Potentials_Netto_Winst in the report..
Now I want to subtract that variable with another variable (also big decimal and initial value expression = 130000) and save the result in a 3rd variable..
How can I do that???
5 Answers:
See Attachment. Is it possible to do calculation with such variable. Because this variable is already a sum of other fields...
When I do some calculations with fixed integers, it works. But everytime when I use the field you see in attachment, the result = null
Attachment | Size |
---|---|
![]() | 10.97 KB |
Sorry, it seems that I misled you. Please let me explain what I did,
first, create a variable named "Summary" do sum and it type as BigDecimal.
second, create a variable named "MinusValue" with Variable Expression "new BigDecimal(130000)"
third, create a variable named "ResultValue" with Variable Expression "$V{Summary}.subtract($V{MinusValue})"
fourth, drag the variable Summary into report and set Evaluation Time of the field to "Report"
last, drag the variable ResultValue into report and set Evaluation Time of the field to "Report"
preview the report and that's all, hope this would help you.
I did that:
<variable name="VasteKost" class="java.math.BigDecimal">
<variableExpression>130000</variableExpression>
<initialValueExpression><![CDATA[]]></initialValueExpression>
</variable>
<variable name="variable1" class="java.math.BigDecimal">
<variableExpression><![CDATA[$V{Potentials_Netto_Winst_(€)_2}.subtract( $V{VasteKost} )]]></variableExpression>
</variable>
But now my Variable 'VasteKost' = null and my subtract result is also null
When I add a variable and add the variable $F{Potentials_Netto_Winst}
The restult = null.. But when i drag the variable $F{Potentials_Netto_Winst} on my report i see the correct result.. So i don't know how I can subtract a value from a variable that is the sum of other values in the report..