Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare Summary or RunningTotal with the previous group

Status
Not open for further replies.

Gus01

Programmer
Sep 4, 2009
45
FR
Hello,
Is there a simple way to compare the sum of a field with the sum of the same field the previous group (like previous() on a simple record) ?

Ex:
group fld1

2006 100
2006 110
2006 120

2007 200
2007 210

-> Sum (fld1, 2007) - sum (fld1, 2006) = (100 +110 +120) - (200 + 210)

And I must also hide the 1st group (2006) ...
Thank you for your help;
 
You could insert a separate running total of each where you specify the group instance in a formula in the evaluation section:

{table.yeargroup} = 2007 //or 2006

Then you could create a formula:

{#sum2007}-{#sum2006}

Another approach would be to create a formula like this to be placed in a group section, which would always subtract the current group sum from the previous group sum:

whileprintingrecords;
numbervar prev;
numbervar curr;
prev := curr;
curr := sum({table.fld1},{table.yeargroup});
curr-prev

-LB
 
Thank you for your reply.
I understand the principle and found a solution that works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top