473,322 Members | 1,510 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,322 software developers and data experts.

Calculate percentage on report from TEXT fields?

ollyb303
Hello,

Trying to help a friend/colleague out with a database and we've both drawn a blank. Not even sure if this is possible.

The database has a table (Table1) with a several columns: ID, QuestionA, QuestionB, QuestionC, etc.

Each of these is populated from a form (Form1) which uses combo boxes with values of YES, NO and NA.

He has created a report which displays the answers to the questions for each record, but wants to calculate the percentage of records where the answer to each question is YES (discounting any where the answer is NA).

i.e. (and I apologise for this format!) (Count of records where QuestionA = "YES") / (Count of records where QuestionA = "YES" or "NO") as a percentage.

Any ideas?

Many thanks
Jan 17 '08 #1
4 5944
PianoMan64
374 Expert 256MB
In order to be able to do that, you would need to enter into a textbox control in it's control source the following line:
Expand|Select|Wrap|Line Numbers
  1. =FORMATPERCENT(DCOUNT("[ID]","[TABLE1]","[YesNoFieldInTable] = True")/TotalNumberOfQuestions,2)
  2.  
The ID field is the Primary Key in the table
Table1 would be the name of the table
YesNoFieldInTable is the name of the field that holds the yes/no or True/False answer
TotalNumberOfQuestions is the number of questions that you're asking.

If the field that holds the answer physicaly has text instead of Logical statement then you would enter the following
Expand|Select|Wrap|Line Numbers
  1. =FormatPercent(DCOUNT("[ID]","[TABLE1]","[YesNoTextFieldinTable] = 'Yes'")/TotalNumberOfQuestions,2)
  2.  
Jan 17 '08 #2
In order to be able to do that, you would need to enter into a textbox control in it's control source the following line:
Expand|Select|Wrap|Line Numbers
  1. =FORMATPERCENT(DCOUNT("[ID]","[TABLE1]","[YesNoFieldInTable] = True")/TotalNumberOfQuestions,2)
  2.  
The ID field is the Primary Key in the table
Table1 would be the name of the table
YesNoFieldInTable is the name of the field that holds the yes/no or True/False answer
TotalNumberOfQuestions is the number of questions that you're asking.

If the field that holds the answer physicaly has text instead of Logical statement then you would enter the following
Expand|Select|Wrap|Line Numbers
  1. =FormatPercent(DCOUNT("[ID]","[TABLE1]","[YesNoTextFieldinTable] = 'Yes'")/TotalNumberOfQuestions,2)
  2.  
Thanks for the reply,

I'm not sure I explained myself properly

We're not trying to calculate the total percentage of questions which were answered "yes" - For each question we need to calculate the percentage of records on which that question was answered "yes" - so the total number of questions is irrelevant.

We would need to add a different textbox for each question which displays total "yes"/total "yes" or "no" for that question only.

Hope that's clearer.

Many thanks
Jan 17 '08 #3
missinglinq
3,532 Expert 2GB
Wouldn't you need to divide the total Yeses for the question divided by the total number of records?

Maybe

Expand|Select|Wrap|Line Numbers
  1. =FORMATPERCENT(DCOUNT("[ID]","[TABLE1]","[YesNoFieldInTable] = True")/DCOUNT("[ID]","[TABLE1]"))
  2.  
Linq ;0)>
Jan 17 '08 #4
Seems odd perhaps, but no. We want to exclude any "NA" answers from the equation completely. Have successfully solved it now with the following:

Expand|Select|Wrap|Line Numbers
  1. =FormatPercent(DCount("[ID]","[Table1]","[QuestionA] = 'yes'")/(DCount("[ID]","[Table1]","[QuestionA]='yes'")+DCount("[ID]","[Table1]","[QuestionA]='no'")))
Many thanks both of you.
Jan 21 '08 #5

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

Similar topics

2
by: KEVIN97810 | last post by:
Hello to all, Access 2000 I have 2 fields on my report and I want to know the percentage of both fields. I tried something like this and it gives me ERROR in the SalesPercentage textbox, ...
1
by: toluj | last post by:
Hi, pls could anyone help me with the script to calculate the percentage btwn two fields in a table.
12
by: paii, Ron | last post by:
Sorry about that last one. Does anyone know how to calculate the width a string of text for given Font name and size? I want to buildup a block of text strings to display in a unbound control,...
39
by: Umesh | last post by:
Plese help. Is there any software by which we can do that?
3
by: tulikapuri | last post by:
Dear Friends, I am using the method to cal. percentage in report but no sucess it gives #Num! instead of a number. I am following the steps as given in help to calculate percentage value on a...
4
by: Micheal | last post by:
Greetings Access Group, Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days...
6
by: plaguna | last post by:
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...
17
by: MNNovice | last post by:
Calculate net amount based on conditions ________________________________________ I need to calculate a net amount that is based on FedRatio. Normally the FedRatio is set to be 80% but there are a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.