count expression for like entries in a field

T

tjproferes

Access Guru's...

I have a table with a field titled "Courtesy". Subjects are rated on a scale
of either 5, 3, or 0.
These entries are input into the field.
In a report that lists all entries in this field, I need to count the entries
that are 3 and 0 only.
I have most recently tried:
=Sum(IIf([courtesy] = "3",1,0))
as a test but this gives back an data mismatch error.
I have also tried other count statements but non can give me a count based on
the criteria.

Any suggestions that you could provide would be great,
Thanx
TJP
 
A

Allen Browne

If Courtesy is a Number field (not a Text field), drop the quotes:
=Sum(IIf([courtesy] = 3, 1, 0))
 
T

tjproferes

Thank you so much for the reply, and that expression does give me a count of
all the "3" that appear. I also need all of the "0"'s that appear in the
same column. Can this be done in the same expression?
Thank you for your time,
TJP

Allen said:
If Courtesy is a Number field (not a Text field), drop the quotes:
=Sum(IIf([courtesy] = 3, 1, 0))
Access Guru's...
[quoted text clipped - 15 lines]
Thanx
TJP
 
A

Allen Browne

That would be another text box, bound to:
=Sum(IIf([courtesy] = 0, 1, 0))

It might be easier to use a crosstab query here, where courtesy is the
Column Heading.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

tjproferes said:
Thank you so much for the reply, and that expression does give me a count
of
all the "3" that appear. I also need all of the "0"'s that appear in the
same column. Can this be done in the same expression?
Thank you for your time,
TJP

Allen said:
If Courtesy is a Number field (not a Text field), drop the quotes:
=Sum(IIf([courtesy] = 3, 1, 0))
Access Guru's...
[quoted text clipped - 15 lines]
Thanx
TJP
 
T

tjproferes

Thank you again, I actually already started making the second text box and
hiding the 2, then adding the 2 in a visible one. A bit teadious but it will
give me the results I need in a printable report for the Sups.
Without your help I would have been pulling my hair out for another couple of
hours.
THANX!!!
TJP

Allen said:
That would be another text box, bound to:
=Sum(IIf([courtesy] = 0, 1, 0))

It might be easier to use a crosstab query here, where courtesy is the
Column Heading.
Thank you so much for the reply, and that expression does give me a count
of
[quoted text clipped - 11 lines]
 
A

Allen Browne

If you wanted to sum the 0's and 3's together, you could use:
=Sum(IIf([courtesy] IN (0,3), 1, 0))
or else:
=Sum(IIf([courtesy] = 0 OR [courtesy] = 3, 1, 0))
or even:
=Sum(IIf([courtesy] = 0, 1, 0)) + Sum(IIf([courtesy] = 3, 1, 0))

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

tjproferes said:
Thank you again, I actually already started making the second text box
and
hiding the 2, then adding the 2 in a visible one. A bit teadious but it
will
give me the results I need in a printable report for the Sups.
Without your help I would have been pulling my hair out for another couple
of
hours.
THANX!!!
TJP

Allen said:
That would be another text box, bound to:
=Sum(IIf([courtesy] = 0, 1, 0))

It might be easier to use a crosstab query here, where courtesy is the
Column Heading.
Thank you so much for the reply, and that expression does give me a
count
of
[quoted text clipped - 11 lines]
Thanx
TJP
 

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