smusba
27th October 2016, 13:43
Dear,
I want to do adding calculation from a previous value with the new value.
For example : line# 2 has value 'X' and line#1 has a value 'Y' I want to add both 'X' and 'Y' for more no of lines. How to program the script for this issue?
Value Pr.Value + Value Final value
1 1 1
3 4 1+ 3
5 9 4 + 5
6 15 9 + 6 .......so on
mark_h
27th October 2016, 15:42
I guess I am not sure why you are doing something like this. I mean you just need to keep track of the last number. So if you are updating a table, find the records you want. Step thru them 1 at time, on the first record set something like oldvalue to the first record value, from then on make oldvalue = to new value + oldvalue. Write the records out.
Maybe if you explain what exactly you are trying to accomplish someone has a better idea on for a solution.
bhushanchanda
27th October 2016, 16:03
Mark, it can be used for various purposes e.g. in YTD calculations where you want to show remaining balance after every transaction line.
For that, you can use report script. Store final value in a variable x. Add that to your report layout. Now, in the before.layout section of the layout you are using do curr.value+x(assuming curr.value holds the current value)
In your case it will be -
Say your layout is detail.1 and your value is X. You will do this -
detail.1:
before.layout:
final.value = final.value + X | X will be your first column and final.value will be printed as second column
Not much of a work.
Ajesh
27th October 2016, 16:06
i didnt even understand the pattern.It looks like some distorted version of Fibonacci..
bhushanchanda
27th October 2016, 17:17
i didnt even understand the pattern.It looks like some distorted version of Fibonacci..
They are just values from some table. Though if interested, here are the algorithms which define the two sequences -
For Value Column (http://oeis.org/search?q=1%2C3%2C5%2C6&language=english&go=Search) and For Final Value Column (http://oeis.org/search?q=1%2C4%2C9%2C15&language=english&go=Search) :)
mark_h
28th October 2016, 00:03
Mark, it can be used for various purposes e.g. in YTD calculations where you want to show remaining balance after every transaction line.
Correct - but the final solution will vary if (a) they are doing it in a table wanting to update, (b) want to do it in a form (c) doing it in a report. The calculation can be simple like you showed - and I believe it is for all 3 solutions. Just a little different on where you do the calculation. Now if they give us more details that "being simple" could become complicated. :)