tkmbe Posted October 13, 2013 Share Posted October 13, 2013 I have a report and need to calculate dependendent of an field some calculations and want to save this caululation in a variable to use in an other field.For example I have a filed with the amount p_value which is an amount but in a string (from database) and want to divide it by 1.21 save this value and subtract from the amount and assign the result to an other variable.How can I do that?I tried to create an variable SUB_TOTALVariable Class: DoubleCalculation: NothingReset type: ReportIncremente type: Nonewhich I try to add value$V{SUB_TOTAL}.add(Double.parseDouble($F{p_value})/1.21)or$V{SUB_TOTAL}.set(Double.parseDouble($F{p_value})/1.21)Nothing works...The ultimate ireport designer guide should have at least an example of using variable this way in my opinion :-(Thanks for any help Link to comment Share on other sites More sharing options...
Teodor Danciu Posted October 14, 2013 Share Posted October 14, 2013 Hi,Can you write the forumla you are looking for using some mathematical notations?It's not clear to me what do you want to subtract from what.Are you looking for the sum of field values divided by 1.21? Something like:SUB_TOTAL = SUM(p_value / 1.21)Thanks,Teodor Link to comment Share on other sites More sharing options...
tkmbe Posted October 14, 2013 Author Share Posted October 14, 2013 Hi TeodorI want to the the following:Get total as double which is saved as string in database TOTAL=Double.parseDouble($F{p_value})and calculate the following SUB_TOTAL=TOTAL/1.21 IVA=TOTAl-SUB_TOTALif field iva_t=1or in case iva_t !=0 SUB_TOTALL=TOTAL IVA=0How can I do that and how can I control the order of calculationsi.e. SUB_TOTAL is calculated before IVA? Link to comment Share on other sites More sharing options...
tkmbe Posted October 16, 2013 Author Share Posted October 16, 2013 HelloI have my calulation now:($F{iva_t} == 1 ) ? (new BigDecimal($F{p_value}).multiply(new BigDecimal($P{CambioDollar}))) : $F{p_value}But I''m unable to save te result in a variable. How can I do that? Does I need scriplet for that?Now I'm doing this calulation in a Textfield expresion. Is it unable to use and save in a variable in Textfields?I need to save because I have a lot of calculations to do with this result ... 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