<p>To keep it as simple as I can, say you have: 3 columns, grouped by ID, so here 3 groups:</p>
<p>id, v1, v2</p>
<p>1, 1, 2</p>
<p>1, 2, 3</p>
<p>2, 1, 1</p>
<p>2, 2, 2</p>
<p>3, 3, 3</p>
<p> </p>
<p>And you want to get per group: previous v1 + v1 + previous v2 + v2</p>
<p> </p>
<p>id, v1, v2</p>
<p>1, <span style="color:#ff0000;">1, 2</span> -> 0+<span style="color:#ff0000;">1 </span>+ 0+<span style="color:#ff0000;">2</span> = 3 (no previous for group so using 0)</p>
<p>1, <span style="color:#00ff00;">2, 3</span> -> <span style="color:#ff0000;">1</span>+<span style="color:#00ff00;">2</span> + <span style="color:#ff0000;">2</span>+<span style="color:#00ff00;">3</span> = 8 </p>
<p>2, <span style="color:#0000ff;">1, 1</span> -> 0+<span style="color:#0000ff;">1</span> + 0+<span style="color:#0000ff;">1</span> = 2 (no previous for group so using 0)</p>
<p>2, <span style="color:#ff8c00;">2, 3</span> -> <span style="color:#0000ff;">1</span>+<span style="color:#ffa500;">2</span> + <span style="color:#0000ff;">1</span>+<span style="color:#ffa500;">3</span> = 7</p>
<p>3, 3, 1 -> 0+3 + 0+1 = 4 (no previous for group so using 0)</p>
<p> </p>
<p>and subtotals for each group</p>
<p>Grp Id1 = 3 + 8 = 11</p>
<p>Grp Id2 = 2 + 7 = 9</p>
<p>Grp Id3 = 4</p>
<p>big total = 24</p>
<p> </p>
<p>What would be the best way to do it? </p>
<p> </p>
<p>I've managed to display the correct values using variables to store the previous values and using 'data' objects and their Expression section to update variable values & make computations, and this displays the correct information for each row, but the subtotals and totals are always wrong... It's as if the Expressions entered in 'data' objects are evaluated multiple times; once going through the details, and another time when generating the group subtotals and totals. Subtotals display either 0s or incorrect values, which seem to suggest that it is a 'previous variable' or multiple issue... Even using variables to keep a subtotal, seems to display erroneous data, which again points to multiple executions of data expressions falsifying results...</p>
<p> </p>
<p>If it wasn't for the grouping, sorting and resetting values, and the fact that the actual formulas are quite complex (involves cos, sins, tan, etc.), doing it via SQL or using computedColumn might be an option...</p>
<p> </p>
<p>Searching online, some mention using scripts; OnCreate for instance and then storing previous values in variables, seems to work for detail row values, but this also seems to fail somewhere... So anyway, is there a guide or do's or don'ts for dealing with previous values in Birt? It seemed relatively simple at first, but after 2 days I'm still not getting correct values!

</p>
<p> </p>
<p>Thanks!</p>