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

Conditional SUM formula 1

Status
Not open for further replies.

mbDutch

MIS
Nov 13, 2007
39
US
Hello - Hopefully an easy one:

I have 1 group which is Group 1: Branch
The detail line contains 3 fields which are Type - Code - Amount

Some sample data of the detail section:

Type Code Amount

Customer ? 500
Customer ? 20
Customer Customer 0
Customer ? 40
Customer Customer 250

Now what I want to do is SUM the amount where Type and Code are both Customer and put it in the group footer which of course is easy enough. However, there are instances where
the detail section will look something like this:

Type Code Amount

Customer ? 400
Customer ? 80
Customer ? 0
Customer ? 0
Customer ? 10

Now because none of the records have both Type and Code as "Customer" I want it to sum ALL the amounts. So what I want my forumla to do is look in the detail section to see if there is a match between Type and Code where they are both "Customer" and if so Sum just the amounts where there is a match, however, is there is no match between Type and Code I want it to Sum all the amounts.

Any help would be greatly appriciated.

Thanks.
 
Create a formula {@match}:

if {table.type} = {table.code} then {table.amt}

Then create a formula for the branch group header or footer:

if sum({@match},{table.branch}) = 0 then
sum({table.amt},{table.branch}) else
sum({@match},{table.branch})

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top