I’m creating a Microsoft Access Report of 6 different questions with “Yes” and “No” answers. I have no problem to count the Yes and Nos with the following formulas for each question in the Report Footer:
=Count(IIf([Q1]=”YES”,0))
=Count(IIf([Q1]=”NO”,0))
My question is: how can I get a percentage of NOs for each question? I tried to create a new field (Total of Yes) and (Total of No) in my query with the above formulas, that way I can manipulate fields on the Report, but It didn’t work. So, I’m trying to work it out on my Report. The basic formula would be (Count of NOs Divided by Total Yes and NOs) How can I translate this in the Report Footer.
Please, can somebody help me? Thanks in advance.
I’m using MS Access 2007.
Plaguna
6 5920
Hi plaguna. If this approach is working for you then the simplest way to do what you ask is to OR the two elements: - =Count(IIf(([Q1]=”YES”) OR ([Q1="NO"),0))
There are other ways to do this that would be more flexibile, in particular by adding calculated fields to the report's underlying query, but as your approach is working there is no good reason to change it at present.
-Stewart
Ooh dear - I am very sorry plaguna; instead of replying to your question about how to total your field I have overwritten it - I do apologise. You had asked how to create a percentage in your report representing the number of "No" responses divided by the total responses, now that you had the total itself. I have split my overwritten reply to your question out from what was your post, which unfortunately I had removed from my reply. Sorry for this very silly mistake. -Stewart
Hi plaguna. To get the percentage you need to use a similar COUNT approach to what you have done already. In your percentage textbox set its control source to - =100 * Count(IIF([Q1]="NO", 0))/Count(IIf(([Q1]=”YES”) OR ([Q1="NO"),0))
This is not a flexible or elegant solution, as it repeats the counting of the underlying data. This is why I mentioned in my previous post that the approach I would use is to put the base data for such calculations into the report's base query instead, where the counts etc are done just once.
Although what is listed should work, for reporting on questionnaire responses it would be more normal to base your report on a totals query which provides for each question the total number of responses, and a count of the individual responses provided. Basing your report on such a query you could then do percentages and other calculations (averages, minimums and maximums and so on) without repeating the counting of fields over and over again.
Do as much of the work outside of the report as possible, using calculated fields in the base query to set up useful summary data for your report.
-Stewart
Stewart,
Don’t worry about overwriting my reply. The most important is that I can see that you understand my question.
I tried the code you gave me:
=100 *Count(IIF([Question]="NO", 0))/Count(IIf(([Question]=”YES”) OR ([Question]="NO"),0))
and it didn’t work. I tried this:
= 100 *Count(IIF([Question]="No", 0))/Count(IIf([Question]=”Yes”,1,0))
and it keeps asking me to enter parameter value “Yes” all the time. It gives me the percentage of NOs only after I enter the value (# of Yes). If I could be able to generate the value that I’m looking for automatically, would be great.
I understand your point when you say that the approach you would use is to put the base data into the report's base query instead, and do as much of the work outside of the report as possible. I apologize for my limited level of knowledge but, I don’t know how to get a single value (percentage) in a query when there are more than one answer in a column. I tried different ways, and Iooked for different sources but, I guess I’m missing something. If you can give me a clue or something that I can work on, would be a big help
Thank you again.
Plaguna
Hi again plaguna. I checked the code again and found one inconsistency which I had not noticed first time round.
In the part which you now have as IIf([Question]=”Yes”,1,0) the double quotes are not plain double quotes but word processor-type closing quotes. These were included when I copied that section of your first post.
The revised version with the corrected type of quotes is: - =100 * Count(IIF([Question]="NO", 0))/Count(IIf(([Question]="YES") OR ([Question]="NO"),0))
For the base query approach there are two stages:
1. instead of referring to the table of answers directly add the table to a query in which you can place calculated fields
2. devise a totals query which summarises the data in the answers query
Without full details of the structure of your tables and the type of question and answer it is difficult to give you a correct way to calculate the percentage without making possibly incorrect assumptions.
The percentage of No answers is just (number of Nos) / (number of answers) * 100, but to be correct you need to be clear about the responses: are answers always just Yes or No? Is there also a Maybe, say? Can a respondent leave the question blank, and if so is this to be left out of the calculation, as I would expect?
Assuming that answers can only be Yes or No it is not necessary to count both Yes and No answers, because the count of No's is just the number of answers less the number of Yes's (and vice versa).
The stage 1 query is like this: - SELECT QNumber, Answer, IIF(Answer="YES", 1, 0) as CountYes FROM Answers;
Assuming this was named qryStage1, the stage2 query which does the percentage is then - SELECT QNumber, Sum(countYes) as TotalCountYes, Count(Answer) - Sum(CountYes) as TotalCountNo,
-
Sum(CountYes)/Count([Answer]) * 100 as PercentYes, (1 - (Sum(CountYes)/Count([Answer]))) * 100 as PercentNo
-
FROM qryStage1
-
GROUP BY QNumber;
These are ideas for you to try out when you have time to investigate other solutions.
-Stewart
Stewart,
Thank you very much. It works perfectly. I love it !!!! I tried the two approaches you suggested and both work without any problem. I really appreciate it.
PLaguna
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Marie |
last post by:
How do you display a total from a subreport on the main report. If it makes
a difference, the total is a total of a calculated field (Qty * Price). Does
the total on the subreport go in the pagefooter or report footer? Say the
total is shown in a texrbox named MyTotal and the subreport control is named
MySubreportControl, what exactly do I put in the control source of a textbox
on the main report to show the total?
Thanks For All Help!
...
|
by: Mike |
last post by:
Hello All,
I have a report based upon a query. I have added a control to report
footer that calcs the total cost of the inventory: =SUM().
When this total calculation is NOT on the report, the report displays
as it should in ascending order by inventory number (inv_num).
1102
1103
|
by: Pecanfan |
last post by:
Hi,
I've got an access report which contains a sub-report. The sub-report
contains various items in a group Footer which culminates in a running sum
text box called txtGrandTotal. I want to use this 'total' in the main
report so I have a text box with the following:-
=(!!.!)
For some reason, which I'm sure is perfectly obvious but I'm buggered if I
|
by: SueB |
last post by:
Greetings. I have a report based on the following query (hang in there
... it's quite long):
SELECT Year(.) AS Yr, tblEvents.eventID,
tblEvents.eventname, tblEvents.eventhost, tblEvents.eventcity,
tblEvents.eventstate, tblEvents.eventstartdt, tblEvents.eventenddt,
tblTrials.trialnbr, tblTrials.trialdt, tblTrialClass.trialclassID,
tblClasses.class, tblScores.score, tblScores.level, .
& (" "+.+".") & " " & . & ("
"+.+".") & " (" & . & ",...
|
by: Jana |
last post by:
Using Access 97.
Background:
I have a main report called rptTrustHeader with a subreport
rptTrustDetails in the Details section of the main report. The main
report is grouped by MasterClientID. There are also several other
subreports in the main report's footer. The rptTrustDetails subreport
has two grouping levels MasterClientID and ClientID, with headers and
footers for each grouping level. In the ClientID footer, I have an...
| |
by: Sunil Korah |
last post by:
Hi,
I haven't used access reports much. I have a problem in getting the
total of a group.
I have 3 fields, ProgName (Program name), Pname (Participant's name)
and PCategory (Participant category)
PCategory can have values 'SC', 'ST' and 'Others'
|
by: bobw2961 |
last post by:
I have what I hope is a simple question for some of you. I have two
fields. Quantity and Price. I enter a text box named SubTotal in the
detail of the report and set the control source to
=*. This works fine and I have all the correct
values in the detail of the report. Now at the bottom of my report I
want a total. I insert a text box in the report footer named Total
and set the control source to =sum(). This does not work.
I get...
|
by: dan.cawthorne |
last post by:
Kinda Confused to why i cant get a single text field to add up all the
Projects that are filtered Via a Query.
I Have a Query Based on a Projects Table.
The Query Have a Criteria To Select a Estimator, Which Then List all
the Projects that Estimator as worked on.
When Then Opens a List Type Report thats Shows all The Projects
Related to that User. and that Report Theres a Field called
|
by: klarae99 |
last post by:
Hello, I am working in Access 2003 on an inventory database. Right now I am working on a report which will be used to fill in forms that our state requires periodically to collect taxes.
Right now I have a query that determines the items that have sold between two dates and calculates the Gross Sales, Tax Collected and Sales Including Tax. This query is set up with the following SQL:
SELECT tblCat.Categories, tblCat.TaxRate,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |