Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping Data by more than one feild?

Status
Not open for further replies.

Delboy14

Programmer
Jun 21, 2001
213
GB
I have a table with Age and Sex. I want to display a chart which seperates the table into age groups and sex, e.g.
Male(0-4), Female(0-4) etc. How do I group the data to do this? This is the Table below?

Sex AgeAtConsult
Male 4
Female 25
Female 40
Male 55
Female 44
Male 19
Male 28
Female 33


 
Hi,

Create a formula something like:-

If {Age} < 6 then 1
else if {Age} < 10 then 2
else if {Age} < 20 then 3
else 4

Then group on this formula.

Geoff
 
When I try to use this formula, the graph that is produced, does not split up male and females into each goup in the way that I am trying to.

I want the x (group axis) to display each age range and sex so male 0-4 then female 0-4 then male 5-15 etc for each bar. and I want the data axis to show the percentages of how many of the group of people are in each age/sex group. Does anyone know how to do this. I have drawn a graph below to show what I am trying to do. (I do know how to change the number of people in each group to percentages) I also already have a feild for the number of people in the set which is patients seen.

P 100 |
E |
R |
C |
E |
N 50 |
T | ______
A | | |
G | | |
E | | |
S 0 |__|____|_____________________________________________
|Male(0-4)|Female(0-4)|Male(5-15)|Female(5-15)

 
You're a little vague still on what you're trying to do.

Do you want to break by sex and by 10-year brackets:
Male 0-4
Male 5-14
Male 15-24 (etcetera)
Female 0-4
Female 5-14
Female 15-24 (etcetera)

If so, then you need to modify your formula.

GraphGroup:
StringVar outlabel;
If {sex} = &quot;M&quot; Then outlabel := &quot;Male &quot; Else outlabel := &quot;Female&quot;;
If {age} < 5 then outlabel := outlabel + &quot; 00-04&quot;
else if {age} < 15 then outlabel := outlabel + &quot; 05-14&quot;
else if {age} < 25 then outlabel := outlabel + &quot; 15-24&quot;
else if {age} < 35 then outlabel := outlabel + &quot; 25-34&quot;
else if {age} < 45 then outlabel := outlabel + &quot; 35-44&quot;
else if {age} < 55 then outlabel := outlabel + &quot; 45-54&quot;
else if {age} < 65 then outlabel := outlabel + &quot; 55-64&quot;
else outlabel := outlabel + &quot; 65+&quot;;
outlabel

Generate your chart based on GraphGroup and that ought to work.

You may need to play with the labels in order to get them to appear in the order you want; if you want them paired by age group I would define the labels as &quot;00-04 Male&quot; instead of &quot;Male 00-04&quot;.

Richard A. Polunsky
Houston, Texas
 
I have set fields which the data has to be split into, 0-4, 5-15,16-44,45-74 and 75+, for Male and Females. The feilds should be in the order Male, Female for each age group in the graph.

I am trying to create a graph which will display the number of people in each group as a percentage of the total number of people.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top