Summarizing yes and no

G

Guest

TIA:

I have a table with yes/no fld.

I'm trying to generate a report to simply show "#_of_yes" OF
"#_yes_and_no") and calculate the percentage eg (7 of 10 70%). I don't want
to see the "no" data in the report.

Any ideas on approach?

I have tried report based on summay query but the "no" data is there.

Thanks,

Joel
 
J

Jeff Boyce

Joel

Yes & No is stored as -1 (or 1) and 0. You could "add" the responses and
use the absolute value function to make sure it is a positive number -- that
gives you the number of yes'es.

Or you could create a totals query and count WHERE YourField = "True" (and
once more, with "False").

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

Thanks Jeff:

I misspoke..it is a text field with yes, no, and other, so the math approach
is moot.

I have tried a summary query with criteria for "yes or no" and counts of
each but the "no" data is now part of the report. I'm tring to only show the
yes and total data.

How would i use a summary query in a report and not show one of the groups?
Or do I need two different queries and then how to make one report with 2
queries (one for yes and one for total yes and no)?

Joel
 
G

Guest

Long way around but it works.

Summary queries for yes and no to get counts.

Then create report for each. On main report, add subreports and create text
box to add 2 together and textbox to calculate % and hide subreport for "no"
data.

Any eaiser way?

TIA,
Joel
 
G

Guest

To count the number of records where [UnknownField] contains "Yes" use a
control source of:
=Sum( Abs([UnknownField]="Yes"))
If you don't want to display records in your report with [UnknownField] =
"No" but you need them available for counting, you can use code to cancel the
printing of a record where the [UnknownField] ="No"
In the On Format event of the report section:
Cancel = ([UnknownField] = "no")
 
J

John Spencer

Simple query

SELECT Abs(Sum([SomeField] = "yes")) CountYes
, Count([SomeField]) as CountResponses
, Abs(Sum([SomeField] = "yes")) / Count([SomeField]) as ThePercent
FROM [Your Table]

In the query grid
-- Add Somefield to the query twice
-- Change first field to Abs([SomeField= "yes")
-- Select View: Totals from the menu
-- Change first group by to Sum
-- Change second group by to Count



'====================================================
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