473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Create a Total Percentage in the Report Footer

58
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
Jul 8 '08 #1
6 5883
Stewart Ross
2,545 Expert Mod 2GB
Hi plaguna. If this approach is working for you then the simplest way to do what you ask is to OR the two elements:
Expand|Select|Wrap|Line Numbers
  1. =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
Jul 9 '08 #2
plaguna
58
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
Jul 9 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
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
Expand|Select|Wrap|Line Numbers
  1. =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
Jul 9 '08 #4
plaguna
58
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
Jul 9 '08 #5
Stewart Ross
2,545 Expert Mod 2GB
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:
Expand|Select|Wrap|Line Numbers
  1. =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:
Expand|Select|Wrap|Line Numbers
  1. 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
Expand|Select|Wrap|Line Numbers
  1. SELECT QNumber, Sum(countYes) as TotalCountYes, Count(Answer) - Sum(CountYes) as TotalCountNo, 
  2. Sum(CountYes)/Count([Answer]) * 100 as PercentYes, (1 - (Sum(CountYes)/Count([Answer]))) * 100 as PercentNo
  3. FROM qryStage1
  4. GROUP BY QNumber;
These are ideas for you to try out when you have time to investigate other solutions.

-Stewart
Jul 10 '08 #6
plaguna
58
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
Jul 11 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
5
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,...
3
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...
7
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,...
2
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. ...
7
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...
2
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 =*. ...
1
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...
2
klarae99
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.