473,806 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding Totals for creating percentages in reports

13 New Member
I have a table with four fields: BlockNo, District, SubDate, Status. I would like to create a report that 1)shows the percent of BlockNo that has a SubDate(IsNotNu ll) grouped by District and 2) shows the percent of BlockNo with SubDate(IsNotNu ll) and with Status=Y grouped by District.
I was able to create queries for both of these and count the number of blocks in the query. What I am unable to figure out is how to refer to the TOTAL BlockNo in the table so I can get the percent.
I'm guessing I have to do this in the report. I can get the Totals and Percent from the Queries but that's not what I want. Am I going about this wrong? Should I be doing all the calculations in the report by referring directly to the table and ignoring the queries altogether?
Mar 18 '08 #1
7 2352
MindBender77
234 New Member
All that your asking can be done in a query. I recommend performing all of you calculation the queries and display them using reports. As for your problems, when you say "refer to TOTAL BlockNo" what do you mean.

Could you supply the sql from your query?

Bender
Mar 18 '08 #2
Bernice J
13 New Member
All that your asking can be done in a query. I recommend performing all of you calculation the queries and display them using reports. As for your problems, when you say "refer to TOTAL BlockNo" what do you mean.

Could you supply the sql from your query?

Bender
Hi,
I was able to create two queries. One that showed all blocks with a subdate one that showed all blocks with a subdate and a status=y. However when I create the report based on the queries and ask it to show me the percent of blocks with a subdate OR the percent of blocks with a subdate and status=y it bases the percent on the total of the query not on the total of all the blocks in the database.
Understand? Anyway here is the query code for the first query:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW Count(OperationPlan.BlockNo) AS CountOfBlockNo, OperationPlan.District, OperationPlan.SubDate, OperationPlan.Status
  2. FROM OperationPlan
  3. GROUP BY OperationPlan.District, OperationPlan.SubDate, OperationPlan.Status
  4. HAVING (((OperationPlan.SubDate) Is Not Null));
2nd query:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW OperationPlan.BlockNo, OperationPlan.District, OperationPlan.SubDate, OperationPlan.Status, Count(*) AS [Count Of OperationPlan]
  2. FROM OperationPlan
  3. GROUP BY OperationPlan.BlockNo, OperationPlan.District, OperationPlan.SubDate, OperationPlan.Status
  4. HAVING (((OperationPlan.SubDate) Is Not Null) AND ((OperationPlan.Status)="Y"));
Thanks for taking the time to look at this.
Mar 25 '08 #3
Scott Price
1,384 Recognized Expert Top Contributor
Hi Bernice,

I came over to this thread to get a better understanding of what you are trying to accomplish in Using Count and IIF in Report Control Box

Here's a suggestion based on two queries that I set up in my test database.

Expand|Select|Wrap|Line Numbers
  1. SELECT Count(OperationPlan.SubDate) AS CountOfSubD
  2. FROM OperationPlan
  3. HAVING (((Count(OperationPlan.SubDate)) Is Not Null) AND ((OperationPlan.Status)=-1));
  4.  
Expand|Select|Wrap|Line Numbers
  1. SELECT Count(OperationPlan.District) AS CountOfDistrict, Count(OperationPlan.SubDate) AS CountOfSubDate, Format([countofSubdate]/[CountofDistrict],"Percent") AS Expr1, Query9.CountOfSubD, Format([CountOfsubd]/[CountOfDistrict],"Percent") AS Expr2
  2. FROM OperationPlan, Query9
  3. GROUP BY Query9.CountOfSubD
  4. HAVING (((Count(OperationPlan.SubDate)) Is Not Null));
I entered 7 records as sample data, with a mix of subdates/nulls/statuses.

The second query returns this:

CountOfDistrict s = 7;
CountOfSubDates = 5;
PercentOfDistri ctswithSubDates = 71.43%;
CountOfSubDates withStatusY = 3;
PercentOfDistri ctswithSubdates ANDStatusY = 42.86%

Is this something like you are looking for?

Regards,
Scott
Mar 27 '08 #4
Bernice J
13 New Member
Hi Bernice,

I came over to this thread to get a better understanding of what you are trying to accomplish in Using Count and IIF in Report Control Box

Here's a suggestion based on two queries that I set up in my test database.

Expand|Select|Wrap|Line Numbers
  1. SELECT Count(OperationPlan.SubDate) AS CountOfSubD
  2. FROM OperationPlan
  3. HAVING (((Count(OperationPlan.SubDate)) Is Not Null) AND ((OperationPlan.Status)=-1));
  4.  
Expand|Select|Wrap|Line Numbers
  1. SELECT Count(OperationPlan.District) AS CountOfDistrict, Count(OperationPlan.SubDate) AS CountOfSubDate, Format([countofSubdate]/[CountofDistrict],"Percent") AS Expr1, Query9.CountOfSubD, Format([CountOfsubd]/[CountOfDistrict],"Percent") AS Expr2
  2. FROM OperationPlan, Query9
  3. GROUP BY Query9.CountOfSubD
  4. HAVING (((Count(OperationPlan.SubDate)) Is Not Null));
I entered 7 records as sample data, with a mix of subdates/nulls/statuses.

The second query returns this:

CountOfDistrict s = 7;
CountOfSubDates = 5;
PercentOfDistri ctswithSubDates = 71.43%;
CountOfSubDates withStatusY = 3;
PercentOfDistri ctswithSubdates ANDStatusY = 42.86%

Is this something like you are looking for?

Regards,
Scott
This is getting there. However I'm not counting districts.I want to Group by District and have for each District the Percent of all records with a Subdate and the Percent of records with a SubDate and Status=Y
I will try to modify your code and see what happens. Thanks.
Mar 27 '08 #5
Scott Price
1,384 Recognized Expert Top Contributor
Let me know if you come up with a more elegant solution, but the one I came to uses 4 queries:

Query #1 Groups by and Counts the Districts:
Expand|Select|Wrap|Line Numbers
  1. SELECT OperationPlan.District, Count(OperationPlan.District) AS CountOfDistrict
  2. FROM OperationPlan
  3. GROUP BY OperationPlan.District;
  4.  
Query #2 Groups by District and Counts SubDates:
Expand|Select|Wrap|Line Numbers
  1. SELECT OperationPlan.District, Count(OperationPlan.SubDate) AS CountOfSubDate
  2. FROM OperationPlan
  3. GROUP BY OperationPlan.District;
  4.  
Query #3 Groups by District and Counts SubDates where Status = Y (or -1 using a Yes/No data type for the field)

Expand|Select|Wrap|Line Numbers
  1. SELECT OperationPlan.District, Count(OperationPlan.SubDate) AS CountOfSubDateStatusY
  2. FROM OperationPlan
  3. GROUP BY OperationPlan.District, OperationPlan.Status
  4. HAVING (((Count(OperationPlan.SubDate)) Is Not Null) AND ((OperationPlan.Status)=-1));
  5.  
Query #4 ties them all together and does the calculation to obtain the percentage:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW Query10.CountOfSubDate, Query11.CountOfDistrict, Format([CountOfSubDateStatusY]/[CountOfDistrict],"Percent") AS Expr1, Format([CountOfSubDate]/[CountOfDistrict],"Percent") AS Expr2, Query9.CountOfSubDateStatusY
  2. FROM (Query9 INNER JOIN Query10 ON Query9.District = Query10.District) INNER JOIN Query11 ON Query10.District = Query11.District
  3. GROUP BY Query10.CountOfSubDate, Query11.CountOfDistrict, Format([CountOfSubDateStatusY]/[CountOfDistrict],"Percent"), Format([CountOfSubDate]/[CountOfDistrict],"Percent"), Query9.CountOfSubDateStatusY;
The results that come from the fourth query:

CountOfDistrict : 3, 4
CountOfSubDate: 2, 3
CountOfSubDateS tatusY: 1, 2
%1: 66.67%, 75.00%
%2: 33.33%, 50.00%

Regards,
Scott
Mar 27 '08 #6
Scott Price
1,384 Recognized Expert Top Contributor
You'll notice that in the sql for the fourth query the names of the different queries are Query9, Query10, Query11... Not important, just the names that happened to default when I did this in my test db. You'll change them, of course, to the names of the queries you end up using in your db.

Regards,
Scott
Mar 27 '08 #7
Bernice J
13 New Member
You'll notice that in the sql for the fourth query the names of the different queries are Query9, Query10, Query11... Not important, just the names that happened to default when I did this in my test db. You'll change them, of course, to the names of the queries you end up using in your db.

Regards,
Scott
I've been able to get all items calculating correctly except for one. In the District footer for the following example if I use Count or DCount I get a number that does mean anything. If I use Sum I get the correct number but it is a negative value. Both the Status and Subdate fields are text so I don't know how it is summing and giving the correct number. Any ideas on how I can get rid of the negative?

This is the code that gives a different(but correct) number for each District but is negative.
Expand|Select|Wrap|Line Numbers
  1. =Sum(([STATUS]='Y') And ([SUBDATE] Is Not Null))
This code gives me a total count of all subdates with status=y but it gives the same result for every district.
Expand|Select|Wrap|Line Numbers
  1. =DCount("[SubDate]Is Not Null","OperationPlan","[Status]='Y' ")
Mar 28 '08 #8

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

Similar topics

2
2219
by: TadPole | last post by:
Hi all, My main problems are::::::::: 1. Set a value within a block container that can be used and changed by subsequent templates/block-containers/tables etc.. 2. get/determine/find the setting that tell the process that the new top of the document region is now at the end of the last block-container used, this must be set in that last block container. 3. find the value used in the 'top" setting on the prior
2
2157
by: Nothing | last post by:
I have a main report with several sub-reports on it. Some of the sub-reports are hidden some are visible. A few of the sub-reports hve totals calculated on them. I have a control in the sub-report footer that has a total in it. When I try to reference that control on the main reports header section it seems to be reading just one line of the detail in the sub-report. Not the control with the total. For the life me I can not figure out...
1
1330
by: Eli via AccessMonster.com | last post by:
I have a database of accepted and not accepted reports. If a report is accepted...there is a check box that is marked to show acceptance. When I run a query of "accepted reports" I get a number of 503...........however when I just run a filter by selection on the entire database for "accepted reports"....I get a number of 498.......... To what could I owe the difference of 5 between the two......it's such a small number it's driving me...
6
2945
by: KashMarsh | last post by:
Trying to show running totals on a report, except it needs to show one total amount and values being subtracted from it. For example, the report shows a Total Inventory amount (TotInvAmt). And then amounts for each month for the orders like JanAmt, FebAmt, etc. I want to show under each month column the following: (TotInvAmt)-(JanAmt)=B ----result shows under the Jan column B-(FebAmt)=C ---------result shows under the Feb column...
3
1974
by: brm6546545 | last post by:
I have a tblTax. It has fields InvoiceNum, TaxAuthority, TaxableTotal, NonTaxableTotal, TaxCollected. Sample data 1,county,10.00,0.00,0.40 1,city,10.00,0.00,0.10 2,state,0.00,15.00,0.15 When totaling invoice 1 should have totals of 10.00,0.00,0.50 because
2
2251
by: Tom | last post by:
All: I have a report that lists quantities of stuff used over the course of a year and it is grouped on each month. In the group footer I want to insert the total for the month - easy stuff so far. The part that has me stumped is that the units of use for each record may not be the same (e.g., we may have one record at 5 lbs and one with 4 kg). I've gone to some length in the forms for entering data to prevent this, but I subscribe...
4
5668
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 (total 10 hours) and I have yet to resolve it. please excuse me for my lack of terminology, I will try to provide you with the best of information. I currently have a report that contains 2 totals and the percentage of the difference of the 2...
5
3954
prn
by: prn | last post by:
Hi folks, I'm looking for a little advice here. I need to create a report that is totals only, with no detail records. I have a database with a lot of individuals (people) and the report has to have some overall totals, totals per state, totals by gender, race/ethnicity, and several other criteria. This report does not need to (and should not) report on each individual, just the totals. I can create expressions for each of the items I...
3
2083
by: martin DH | last post by:
Access 2003 I have a table (TASKS) filled with data from an external source. The table lists several tasks for employees to complete and has a text field (STATUS) that identifies where in the completion process the task is by a single alpha character (e.g. C=Complete, N=Not Started, A=Actively Working, W=Waiting, and X=Not Applicable). I have reports that query the table and provide reports specific to a task or to who is responsible for...
0
9719
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, 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...
0
9597
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,...
0
10620
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, 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...
1
10372
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9187
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, 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...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
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 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.