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

Trying to get a running sum that excludes negative values in a report

Status
Not open for further replies.

Bandenjamin

Programmer
Oct 18, 2005
649
US
Ok this is a little weird and I hope easy. I have a report where certain items are counted and totaled. To make a long story short I have a text box that will occasionally generate negative numbers. What I am trying to get is a total of all the positive numbers, ingnoring the negative ones. The totals are calculated over each group. The one I am working with is currently has a control source on it with the following

=[Text150]-7

Because [Text150] can be any number from 0-12 this can generate negative numbers. I have tried using a third box to calculate this with a control source of

=Sum(IIF(Text154]>=0,[Text154],0)) But that generates an error.

I also tried
=[Text154]>=0 But this gives me either a 0 for negatives and -1 for anything else (I want to count the actual numbers)

Hope that's not too super confusing. Any help is hugely appreciated.

Thanks

Dan
 
Have you tried:
=Sum(IIF([Field150]-7>=0,[Field150]-7,0))
Where Field150 is the field contained by text150.
 

Create a calculated field in the query behinf the record with a source of

iif(field150>0,field150,0)

and run the calculated sum on thet field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top