Count with Criteria?

  • Thread starter Thread starter Poida3934
  • Start date Start date
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.
 
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
..
 
Back
Top