How to count a field if the numbers are <0

B

Bonnie

I have a field that calculates a number. In the footer I want to count only
the numbers that are less than zero. What expression doI use?
 
A

AlCamp

Bonnie,
In the query behind the report, add a column like this...
NegCount : IIF(MyCalc < 0, 1, 0)
Then in the appropriate footer...
= Sum(NegCount)
will yield the number of Negative calculations.
hth
Al Camp
 
M

Marshall Barton

Bonnie said:
I have a field that calculates a number. In the footer I want to count only
the numbers that are less than zero. What expression doI use?


Bonnie, Bonnie, Bonnie. You don't really mean to use the
word "field" here do you? If it really is a field in the
report's record source table/query, then you can use a text
box expression like:
=Abs(Sum([field] < 0))

But, you probably meant to use the word "control", in which
case you might be able to use something like:
=Abs(Sum((expressionthatcalculatesthenumber) < 0))

If the calculation is too complex for that, then you need to
use a running sum text box. Add a text box named
txtRunCount to the detail section. Set its expression to
=-(nameofcalculatedcontrol < 0)
and set its RunningSum property to Over All.
Then the footer text box can display the desired count with
=txtRunCount
 
Top