Re: Query Too Complicated
- From: John Spencer <spencer@xxxxxxxxxx>
- Date: Mon, 11 Jun 2007 20:08:01 -0400
You could try the following
Q02: Format(Sum(IIf([Did Rep Resolve Your Issue?])="Yes",1,0)) /
Count([Did Rep Resolve Your Issue?]) * 100,"#0.0")
Your real problem is that your structure is wrong. You really needed someting more like a table with with the questionID, the responderID, and the response. With that structure the query would be almost trivial.
Since is it probably to late to restructure your table, then you are stuck with the above complicated query.
You might be able to fix this with a union query although twenty questions may cause this to fail. For example with three questions you could build a UNION query that looked like the following and save it.
Note that UNION queries cannot be built using the query grid, but must be built in the SQL view.
SELECT "Q1" as QuestionID, [Question One] as Response
FROM YourTable
UNION ALL
SELECT "Q2" as QuestionID, [Question Two] as Response
FROM YourTable
UNION ALL
SELECT "Q3" as QuestionID, [Question Three] as Response
FROM YourTable
Save that as qNormal.
Now all you need is a query like the following to get the percentage responses for all the questions and responses.
SELECT QuestionID
, Response
, Count(Response)/
(Select Count(Response)
FROM qNormal as T
WHERE T.QuestionID =qNormal.QuestionID)
FROM qNormal
GROUP BY QuestionID, Response
'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
treysoul wrote:
As a caviat to this, all of the data is not Yes or No....some is rank 1-10, and one is "likely" "unlikely"....
"KARL DEWEY" wrote:
Rep Resolve Your Issue?]))*100),4)Q02: Left(((Sum(IIf(([Did Rep Resolve Your Issue?])="Yes",1,0))/Count([Did
- Follow-Ups:
- Re: Query Too Complicated
- From: treysoul
- Re: Query Too Complicated
- Prev by Date: Re: Requery Combo Box
- Next by Date: RE: IIF Statement in a Query.
- Previous by thread: RE: Count Function
- Next by thread: Re: Query Too Complicated
- Index(es):
Relevant Pages
|