samhast Posted April 19, 2013 Share Posted April 19, 2013 I have one variable:BigDecimalCalculation = SumRest Type = reportVariable 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 More sharing options...
hawkx Posted April 19, 2013 Share Posted April 19, 2013 Try this, first, the two variable should both be BigDecimal, then set expression for the 3rd variable as $V{v1}.subtract($V{v2}) Link to comment Share on other sites More sharing options...
samhast Posted April 19, 2013 Author Share Posted April 19, 2013 I did that:Variable 3:Variable Expression = $V{Potentials_Netto_Winst}.subtract( $V{Potentials_Totaal_Kosten_(€)_1} )Result = null Link to comment Share on other sites More sharing options...
hawkx Posted April 19, 2013 Share Posted April 19, 2013 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) Link to comment Share on other sites More sharing options...
samhast Posted April 19, 2013 Author Share Posted April 19, 2013 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 More sharing options...
samhast Posted April 19, 2013 Author Share Posted April 19, 2013 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 More sharing options...
samhast Posted April 19, 2013 Author Share Posted April 19, 2013 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 More sharing options...
samhast Posted April 19, 2013 Author Share Posted April 19, 2013 Solved --> evaluation time of my textfield = 'Now'. I changed it to Report.. Now it's ok.. Link to comment Share on other sites More sharing options...
hawkx Posted April 19, 2013 Share Posted April 19, 2013 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now