Counting yes/no fields on a report

J

javajoe128

Hello,

I have a report with a yes/no field for which I would like to count the
number of "Yes" responses on. I created a calculated control using an
"IIF " statement. The formula is written as follows:

IIF ([field name X] = -1, sum[[field name x], 0)

The problem with this formula is that Access evaluates the first value
on the report and if it is not equal to "-1" it then puts "0" as the
result even if the 2nd or 3rd or other values proceeding the first
value = "-1".

How can I get Access to evaluate each rows result independently and
then sum only those that meet the criteria?

Thanks in advance.
 
J

javajoe128

Hello,

I have a report with a yes/no field for which I would like to count the
number of "Yes" responses on. I created a calculated control using an
"IIF " statement. The formula is written as follows:

IIF ([field name X] = -1, sum[[field name x], 0)

The problem with this formula is that Access evaluates the first value
on the report and if it is not equal to "-1" it then puts "0" as the
result even if the 2nd or 3rd or other values proceeding the first
value = "-1".

How can I get Access to evaluate each rows result independently and
then sum only those that meet the criteria?

Thanks in advance.


NO NEED TO REPLY: I located the answer.
 
J

John Spencer

Oh so close!!!!! Just did things in the wrong order

SUM (IIF ([field name X] = -1, 1, 0))

Or even simpler with yes/no fields

Abs(SUM([Field Name X]))

This sums all the 0 and -1 and then strips off the negative sign using the
Abs function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top