In a VX-Rexx program I have this container, QRY_2:
The problem is that I need the third column in the container, TALLFLT2 (displayed as DATA.3 above), to get updated with cumulative values from column TALLFLT1, also it must «reset» when the value in TEKSTFELT changes, like this:
|TEKSTFELT | TALLFLT1 | TALLFLT2|
|aaa | 10.00| 10.00|
|aaa | 10.00| 20.00|
|aaa | 10.00| 30.00|
|bbb | 100.00| 100.00|
|bbb | 100.00| 200.00|
|bbb | 100.00| 300.00|
|ccc | 1000.00| 1000.00|
|ccc | 1000.00| 2000.00|
|ccc | 1000.00| 3000.00|
Ideas are welcome.
Apart from REXX and VX-Rexx, of which I remember too little, the idea is keeping track of all the equal elements in DATA.1 and increment the cells in DATA.3 by the amount of what is present on the corresponding cell in DATA.2 (convoluted, I know: I'm terribly sleepy today).
One idea would be to follow a SQL-like approach, selecting all distinct elements in DATA.1 and for each cell in DATA.3 sum the actual amount of DATA.2.
Seeing as the rows in DATA.1 are already grouped by equal elements that would be not so difficult.
Another idea, more trivial but clever:
1) keep a counter of the current cell
2) save the current value of DATA.1 in an object, and the current value of DATA.3 in another (current cells)
3) cycle on all elements of DATA.1:
3.1) while DATA.1 is equal to the saved value, add to the current cell of DATA.3 the previous value + DATA.2
3.2) if DATA.1 is different, repeat the cycle saving the new value and starting from empty values of DATA.2 and DATA.3
Clear as fog, I know...
Mentore