Conditional Counting

T

Tina S

I have a table that has survey answers in it.
The answers are either "Yes", "No", "DK" or "N/A".

Example: 10 survey
6 Yess
2 Nos
1 DK
1 N/A

I need to count the yess and then divide this result by the yess and nos.
Example: 6/8 = 0.75

I am a novice to Access so please tell me exactly where I need to put the
info you give me. Thanks.
 
M

MGFoster

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

To divide the Yes answers by the total yes answers and no answers you
should also include the DKs and the N/As to get the actual percent of
Yes answers out of all the answers. Try this:

SELECT SUM(IIf(answer="Yes",1,0)) As YesTotal,
SUM(IIf(answer="Yes",1,0))/COUNT(answer) As PctYesAnswers
FROM Survey_Table

If you really want just the percent of yes answers out of ONLY Yes or No
answers then use this for the PctYesAnswers formula:

SUM(IIf(answer="Yes",1,0))
/ SUM(IIf(answer="Yes" OR answer="No",1,0)) As PctYesAnswers

Change the names of the table and the columns to suit your set up.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSW5pSIechKqOuFEgEQLVLACgk+5H4R1q86L9ceJHLkkPuJX2OpwAoNEe
UwaLYVTHx6FqD6XglGJPmych
=l35D
-----END PGP SIGNATURE-----
 

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