Subtract two variables

0

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???

samhast's picture
92
Joined: Nov 4 2011 - 6:41am
Last seen: 2 years 10 months ago

5 Answers:

0

Try this, first, the two variable should both be BigDecimal, then set expression for the 3rd variable as $V{v1}.subtract($V{v2})

hawkx's picture
40
Joined: Nov 26 2012 - 7:34pm
Last seen: 1 year 8 months ago
0

I did that:

Variable 3:

Variable Expression = $V{Potentials_Netto_Winst}.subtract( $V{Potentials_Totaal_Kosten_(€)_1} )

Result = null

 

samhast's picture
92
Joined: Nov 4 2011 - 6:41am
Last seen: 2 years 10 months ago
0

I made a try, you should change the variable Potentials_Totaal_Kosten_(€)_1, set its property "Variable Expression", not the "Initial Value Expression", set to new BigDecimal(130000)

hawkx's picture
40
Joined: Nov 26 2012 - 7:34pm
Last seen: 1 year 8 months ago

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

samhast - 6 years 5 months ago

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..

samhast - 6 years 5 months ago
0

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

Attachments: 
AttachmentSize
Image icon ireportcalc.png10.97 KB
samhast's picture
92
Joined: Nov 4 2011 - 6:41am
Last seen: 2 years 10 months ago

Solved --> evaluation time of my textfield = 'Now'. I changed it to Report.. Now it's ok..

samhast - 6 years 5 months ago
1

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.

hawkx's picture
40
Joined: Nov 26 2012 - 7:34pm
Last seen: 1 year 8 months ago
Feedback