Jump to content
We've recently updated our Privacy Statement, available here ×

Subtract two variables


samhast

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

I did that:

130000

]]></initialValueExpression></p><p> </variable></p><p> <variable name="variable1" class="java.math.BigDecimal"></p><p> <variableExpression><![CDATA[$V{Potentials_Netto_Winst_(€)_2}.subtract( $V{VasteKost} )

 

But now my Variable 'VasteKost' = null and my subtract result is also null

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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