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

sum with conditions??

Status
Not open for further replies.

gtjr92

Programmer
May 26, 2004
96
Ok I have a report that counts the number of records in a
field (the report does much more than just this trying to
keep things in perspective here) once those records are
counted I then want to get the total value of those items
by adding them up based on data from another field in the
same table. This much I can get to work I set a sum
formula to do that. I want also to only get the sum for
those items in another field where the field is not equel
to "S" When I try the below formula I get "the remaining
text does not appear to be part of the formula, or if i
change the parentheses around some it tells me I need a (
somewhere. Here is the formula I am trying. I can't
change the main query to get this data because that will
change other values in my report that are based on these
fields too.

Sum ({WOEQUIP.WECHAR} -{WOEQUIP.WECHAR}) (Where ({WOEQUIP.WEITYP} Not S))
 
The firt part of your formula:

Sum ({WOEQUIP.WECHAR} -{WOEQUIP.WECHAR})

Makes no sense. This will ALWAYS evaluate to zero. Is this a typo or what are you trying to accompish?

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
I thought I explained myself ok but Sum ({WOEQUIP.WECHAR} -{WOEQUIP.WECHAR}) (Where ({WOEQUIP.WEITYP} Not S))
there is a equipment cost field [wechar] and another field [weitype] I want the sum of the wechar fields where the weityp is NOT "S" So I figure I could get all of the wechar totals (which I do get now) take the total of all of those and subtract the wechar total where weitype is "S"
 
My confusion lies in the first part of your formula, which takes a field then subtracts itself from itself which will always evaluate to zero.

Sum ([red]{WOEQUIP.WECHAR}[/red] - [red]{WOEQUIP.WECHAR}[/red])

This formula would only make sense to me if there were 2 different field names, not the one listed twice in red above.

I think what you want is a formula field as follows:
If {WOEQUIP.WEITYP}="S" then {WOEQUIP.WECHAR} else 0

Place this in the details section, then right click on and and select insert, grand total. Write a similar formula use <>"S" to get the non "S" types.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Thanks that did it. Although I went ahead and made a seperate formula that got the totals instead of the gran total. It would only allow me to put the grand total field as a page footer and not in the details. So I made the other field and place it in details
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top