Count with Criteria?

P

Poida3934

I'm trying to list student records by class groups, and have a group summary
of number of males/females. My report field is either M or F, can I use
count
something like Count([StudGender]="F"). Any help appreciated, particularly
if I'm on the completely wrong track!! Thanks in anticipation.
 
J

John Spencer

Your expression was returning true (a value) or false (a value) to every
line was counted.

You can use Count in combination with an IIF or you can use SUM

=Count(IIF(StudGender="F","F",Null))
Count counts the presence of a value - nuill is not a value. So the first
expression returns "F" or Null.

Or

=Abs(Sum(StudGender="F"))

StudGender = "F" returns True (-1) or False(0). So summing all the values
returns a negative sum of the -1. Using Abs strips off the negative.

You could also use

=Sum(IIF(StudGender="F",1,0))

So, now you have three ways to solve the problem.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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