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
10 4775
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.
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 -
-
TRANSFORM Count(tblTestResults.Age) AS CountOfAge
-
SELECT tblTestResults.testrslt
-
FROM tblTestResults
-
GROUP BY tblTestResults.testrslt
-
PIVOT Partition(Int([Age]),0,100,5);
-
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
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: - SELECT DISTINCTROW [Testrslt], Partition([Age],0,100,5) AS Age_Range, Count([Age]) AS Range_Count
-
FROM tblTest
-
GROUP BY [Testrslt], Partition([Age],0,100,5);
Try: - SELECT DISTINCTROW [Testrslt], Partition([Age],0,100,5) AS Age_Range, Count([Age]) AS Range_Count
-
FROM tblTest
-
GROUP BY [Testrslt], Partition([Age],0,100,5);
OUTPUT From Sample Data: -
Testrslt Age_Range Range_Count
-
Satisfactory 15: 19 2
-
Satisfactory 20: 24 2
-
Satisfactory 50: 54 1
-
Satisfactory 60: 64 12
-
Satisfactory 75: 79 8
-
Unsatisfactory 15: 19 1
-
Unsatisfactory 20: 24 1
-
Unsatisfactory 45: 49 5
-
Unsatisfactory 55: 59 21
-
Unsatisfactory 60: 64 9
-
Unsatisfactory 80: 84 1
-
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 -
-
TRANSFORM Count(tblTestResults.Age) AS CountOfAge
-
SELECT tblTestResults.testrslt
-
FROM tblTestResults
-
GROUP BY tblTestResults.testrslt
-
PIVOT Partition(Int([Age]),0,100,5);
-
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! 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 :))
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!
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!
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...
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.
You can see the full list of all articles here.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |