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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Sums of Multiple Groups

Status
Not open for further replies.

ProgressiveJL

IS-IT--Management
Jul 5, 2006
46
0
0
CA
Hi all,

I'm trying to add the sums of groups based on certain group criteria.

Ie.
Groups are 1, 2, 3, 4, 5. I want to add the sum of groups 1 & 3 & 5.

Any help is much appreciated. Let me know if I've described the problem clearly enough.

Thanks!
John
 
What about if you use an If-Then-Else clause?

Sum(If(Group = 1 ......
 
Thanks for the prompt reply but I'm still working on my problem...

Basically, I have a group and want to sum the values of 2 of the subgroups.

subgroup 1 = 1
subgroup 2 = 4
subgroup 3 = 1

I want to sum subgroups 1 + 2 to get 5.

Thanks again for any assistance!
 
There are several ways to do this. Let's say your group is on {table.ID}, and you want to add {table.amt} for IDs 3 and 5. If you don't have row inflation, you could use a conditional formula like this:

if {table.ID} in [3,5] then {table.amt}

You could then place this in the detail section and right click on it and insert a sum at the grand total level.

Or, you could create a variable, using two formulas:

//{@accum} to be placed in the ID group header or footer:
whileprintingrecords;
numbervar sumgrp;
if {table.ID} in [3,5] then
sumgrp := sumgrp + sum({table.amt},{table.ID});

//{@display} to be placed in the report footer:
whileprintingrecords;
numbervar sumgrp;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top