473,406 Members | 2,404 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,406 software developers and data experts.

Report by Age groups

2
Hello everyone,

I have a table which includes 2 fields, patients age [age] and results of a screening test [testrslt].

The age groups are less than 20, 20 - 24, 25 - 29, 30 - 34, ...65 - 69, 70+
The test result can either be Satisfactory or Unsatisfactory

Is it possible to generate a report on the number of occurrences of each test result type by age group.



Thanks


Will
Sep 11 '07 #1
10 4775
mlcampeau
296 Expert 100+
Hello everyone,

I have a table which includes 2 fields, patients age [age] and results of a screening test [testrslt].

The age groups are less than 20, 20 - 24, 25 - 29, 30 - 34, ...65 - 69, 70+
The test result can either be Satisfactory or Unsatisfactory

Is it possible to generate a report on the number of occurrences of each test result type by age group.

Thanks

Will
You can try something like this:
Create textboxes for each age group and input the following expressions and label each textbox accordingly:
=Sum(IIF([Age] < 20 AND [testrslt]="Satisfactory",1,0))
=Sum(IIF([Age] < 20 AND [testrslt]="Unsatisfactory",1,0))
=Sum(IIf(([Age] Between 20 And 24) AND [testrslt]="Satisfactory",1,0))
etc......
I hope you get the picture with that.
Sep 11 '07 #2
Jim Doherty
897 Expert 512MB
Hello everyone,

I have a table which includes 2 fields, patients age [age] and results of a screening test [testrslt].

The age groups are less than 20, 20 - 24, 25 - 29, 30 - 34, ...65 - 69, 70+
The test result can either be Satisfactory or Unsatisfactory

Is it possible to generate a report on the number of occurrences of each test result type by age group.



Thanks


Will
You might wish to look at the PARTITION function in Access which is specifically intended grouping such as this. The example you can find in help and practice on it using the Northwind database

Search the word PARTITION in Access help

As an idea how it applies in your circumstances imagine you have a table called tblTestResults with two fields one called Age and another called tstrslt .....then the SQL syntax that you can use and paste into the query window 'from here' to support the bandings you speak of is as follows

Expand|Select|Wrap|Line Numbers
  1.  
  2. TRANSFORM Count(tblTestResults.Age) AS CountOfAge
  3. SELECT tblTestResults.testrslt
  4. FROM tblTestResults
  5. GROUP BY tblTestResults.testrslt
  6. PIVOT Partition(Int([Age]),0,100,5);
  7.  
The help on this in Access is fully explanatory

According to your explanation of your data the above SQL statement will display when run a resultant dataset giving you a matrix of two rows representing 'Satisfactory' and 'Unsatisfactory' and cross tabulated number of columns between zero years of age and 100 years of age with each column representing an age band of ie: 20:24, 25:29,30:34,35:39.....and so on. It will only create these columns of course where there exists data in your table to support the output

If you study it you will see the Partition(Int([Age]),0,100,5) is the effective element with the arguments 0 representing the 'start' and 100 representing the 'stop' point and the figure 5 representing the incremental value Access should use to create the output columns

You could always then output the query to excel and do what you wish with the figures produced. This is probably a better option for you because creating an Access report based on the output 'might' (I,m not saying it will but it just might) cause you a problem due to the nature of the dynamic column creation giving you columns according to the data held. The potential problem being that if at some stage you removed from your database 30-34 year old people for instance the report would throw an error on opening because the report would still have a field for that banding

Hope this helps you

Regards

Jim
Sep 12 '07 #3
ADezii
8,834 Expert 8TB
Hello everyone,

I have a table which includes 2 fields, patients age [age] and results of a screening test [testrslt].

The age groups are less than 20, 20 - 24, 25 - 29, 30 - 34, ...65 - 69, 70+
The test result can either be Satisfactory or Unsatisfactory

Is it possible to generate a report on the number of occurrences of each test result type by age group.



Thanks


Will
Try:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW [Testrslt], Partition([Age],0,100,5) AS Age_Range, Count([Age]) AS Range_Count
  2. FROM tblTest
  3. GROUP BY [Testrslt], Partition([Age],0,100,5);
Try:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW [Testrslt], Partition([Age],0,100,5) AS Age_Range, Count([Age]) AS Range_Count
  2. FROM tblTest
  3. GROUP BY [Testrslt], Partition([Age],0,100,5);
OUTPUT From Sample Data:
Expand|Select|Wrap|Line Numbers
  1. Testrslt              Age_Range              Range_Count
  2. Satisfactory          15: 19                   2
  3. Satisfactory          20: 24                   2
  4. Satisfactory          50: 54                   1
  5. Satisfactory          60: 64                  12
  6. Satisfactory          75: 79                   8
  7. Unsatisfactory          15: 19                     1
  8. Unsatisfactory          20: 24                     1
  9. Unsatisfactory          45: 49                     5
  10. Unsatisfactory          55: 59                    21
  11. Unsatisfactory          60: 64                     9
  12. Unsatisfactory          80: 84                     1
  13.  
Sep 12 '07 #4
ADezii
8,834 Expert 8TB
You might wish to look at the PARTITION function in Access which is specifically intended grouping such as this. The example you can find in help and practice on it using the Northwind database

Search the word PARTITION in Access help

As an idea how it applies in your circumstances imagine you have a table called tblTestResults with two fields one called Age and another called tstrslt .....then the SQL syntax that you can use and paste into the query window 'from here' to support the bandings you speak of is as follows

Expand|Select|Wrap|Line Numbers
  1.  
  2. TRANSFORM Count(tblTestResults.Age) AS CountOfAge
  3. SELECT tblTestResults.testrslt
  4. FROM tblTestResults
  5. GROUP BY tblTestResults.testrslt
  6. PIVOT Partition(Int([Age]),0,100,5);
  7.  
The help on this in Access is fully explanatory

According to your explanation of your data the above SQL statement will display when run a resultant dataset giving you a matrix of two rows representing 'Satisfactory' and 'Unsatisfactory' and cross tabulated number of columns between zero years of age and 100 years of age with each column representing an age band of ie: 20:24, 25:29,30:34,35:39.....and so on. It will only create these columns of course where there exists data in your table to support the output

If you study it you will see the Partition(Int([Age]),0,100,5) is the effective element with the arguments 0 representing the 'start' and 100 representing the 'stop' point and the figure 5 representing the incremental value Access should use to create the output columns

You could always then output the query to excel and do what you wish with the figures produced. This is probably a better option for you because creating an Access report based on the output 'might' (I,m not saying it will but it just might) cause you a problem due to the nature of the dynamic column creation giving you columns according to the data held. The potential problem being that if at some stage you removed from your database 30-34 year old people for instance the report would throw an error on opening because the report would still have a field for that banding

Hope this helps you

Regards

Jim
Hey Jim, thought I was the only one in the world that knew about PARTITION! Nice find!
Sep 12 '07 #5
Jim Doherty
897 Expert 512MB
Hey Jim, thought I was the only one in the world that knew about PARTITION! Nice find!
Hahaha the feeling is somewhat like sitting by a lake with a fishing rod theres always a use for it someday

Jim :))
Sep 12 '07 #6
mlcampeau
296 Expert 100+
I have never heard of the Partition function. I had to do something similar on one of my reports and I used the method I suggested up above. It does work, but this is good to know too!
Sep 12 '07 #7
ADezii
8,834 Expert 8TB
I have never heard of the Partition function. I had to do something similar on one of my reports and I used the method I suggested up above. It does work, but this is good to know too!
Being as it invoked some interest, I may actually incorporate it into the Tip of the Week!
Sep 12 '07 #8
mlcampeau
296 Expert 100+
Being as it invoked some interest, I may actually incorporate it into the Tip of the Week!
Not to sound off topic or anything, but where do the old Tip of the Weeks go? When I go to the sticky it only shows this weeks...
Sep 12 '07 #9
ADezii
8,834 Expert 8TB
Not to sound off topic or anything, but where do the old Tip of the Weeks go? When I go to the sticky it only shows this weeks...
Articles ==> Access ==> you'll see all the Tips listed by Topic. Tips are usually retained for a week, then they get transferred to the Articles/Access area.
Sep 12 '07 #10
MMcCarthy
14,534 Expert Mod 8TB
You can see the full list of all articles here.
Sep 13 '07 #11

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

Similar topics

24
by: Michael Malinsky | last post by:
I'm attempting to create a database which will take information from one (perhaps two) tables and utilize that information to return queries to a report designed in Excel. The general idea I...
2
by: Simone | last post by:
Hello. I am using the code below: ------------------------------------------- Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If Me.Section(0).BackColor = vbWhite Then...
1
by: Nothing | last post by:
I have a report that has several groups on it. I want to total for each group. My problem is that I group by a name and under the name I have data that breaks out into several sub-groups for that...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
4
by: Richard Hollenbeck | last post by:
The following query takes about one second to execute with less than 1,000 records, but the report that's based on it takes from 15-30 seconds to format and display. That's frustrating for both me...
15
by: Richard Hollenbeck | last post by:
I tried to ask this question before on the 14th of January but I never got a reply. I'm still struggling with the problem. I'll try to rephrase the question: I have a crosstab query with rows...
0
by: galkas | last post by:
Hello I have got a report, which can run on 3 groups of data: College Faculty School Faculty contains schools. College contains faculties. The report can be run for college, then it includes...
7
by: mrwoopey | last post by:
I have a asp.net application that uses the crystal report viewer control. It displays all of my reports but all of a sudden it started giving me the following error on ONLY two reports: "Fail...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
6
by: Bjorn Sagbakken | last post by:
Hi I have done some work with VS 2005 but no report-issues yet. Now I want to step up, and implement reports for printing and PDF export. I have just briefly studied the build-in report...
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
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
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
jinu1996
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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.