I have a table with about 30-40 columns. Each row of each column has a series
of Y's and N's. I need to count how many Y's and how many N's are in each,
and then get a overall percentage for each column. Is this possible, or is
there an easier way to do it? I am tracking the asnwers to survey questions
if that helps. Thanks!
You've fallen victim to the "each question as a field" trap that is very
common when designing survey data. It's a good spreadsheet design, but a bad
database design! Every time you need to add or remove a question you end up
having to redesign your tables, your forms, your queries, etc.
Much better is to have a normalized design with a table of Questions (with
30-40 *rows* not columns); a table of Questionnaires, with fields for who
answered the survey, when, etc; and a table of Answers, with fields for the
QuestionNo linked to the Questions table, the QuestionnaireID linked to the
Questionnaires table, and a yes/no field (or other datatypes if you wish) for
the answer. Then a simple Totals query can count, average, sum, etc. the
answers for you.
If you're stuck with the current design, you can count the number of Yes
answers by taking advantage of the fact that Yes is stored as a number, -1,
and No as zero: to count the yesses, use an expression like
-([Q1]+[Q2]+[Q3]+[Q4]+...+[Q38])
for Yes, and
38 + ([Q1]+[Q2]+[Q3]+[Q4]+...+[Q38])
for No, assuming 38 questions.
For an example of a normalized survey database, download Duane Hookum's
excellent AtYourSurvey 2000 database:
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='At Your Survey 2000'
John W. Vinson [MVP]