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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate Grouping in a report field

Status
Not open for further replies.

ColdPolarBear

IS-IT--Management
Jan 27, 2010
6
0
0
CA
Need to have a field in a report display age group in a report i.e. 21-25 or 26-30. I need the age grouping to appear for each individual record in the report. I will then use the groupings to generate a bar graph in the same report. Please advise if teh code I am using is missing something or if ther is a better way to achive this result I would be interested.


IF {@AgeAtTimeOfComplaint}<20 Then "< than 20"
ELSE IF {@AgeAtTimeOfComplaint}Between 20 and 26 Then "21 - 25"
Else IF {@AgeAtTimeOfComplaint}Between 26 and 30 Then "26 - 30"
Else IF {@AgeAtTimeOfComplaint}Between 31 and 35 Then "31 - 35"
Else IF {@AgeAtTimeOfComplaint}Between 36 and 40 Then "36 - 40"
Else IF {@AgeAtTimeOfComplaint}Between 41 and 45 Then "41 - 45"
Else IF {@AgeAtTimeOfComplaint}Between 46 and 50 Then "46 - 50"
Else IF {@AgeAtTimeOfComplaint}Between 51 and 55 Then "51 - 55"
Else IF {@AgeAtTimeOfComplaint}Between 56 and 60 Then "61 - 65"
Else IF {@AgeAtTimeOfComplaint}> 65 Then "> than 64"
End IF
 
You need to show the content of your age formula.

-LB
 
The Age formula is built upon other formulas.
Q: Is it necesary to break down any/all formula(s) used in this situation?
 
I wanted to see what the calculation is--whether it returns an integer or not, etc.

In general, the formula would more likely be accurate if you used an if/then like this:

if {@AgeAtTimeOfComplaint} < 21 Then
"< 21" else //you left out age 20
if {@AgeAtTimeOfComplaint} < 26 then
"21 to 25" else
if {@AgeAtTimeOfComplaint} < 31 then
"26 to 30" else
if {@AgeAtTimeOfComplaint} < 36 then
"31 to 35" else
if {@AgeAtTimeOfComplaint} < 41 then
"36 to 40" else
if {@AgeAtTimeOfComplaint} < 46 then
"41 to 45" else
if {@AgeAtTimeOfComplaint} < 51 then
"46 to 50" else
if {@AgeAtTimeOfComplaint} < 56 then
"51 to 55" else
if {@AgeAtTimeOfComplaint} < 61 then
"56 to 60" else
if {@AgeAtTimeOfComplaint} < 66 then
"61 to 65" else
if {@AgeAtTimeOfComplaint} >= 66 then
"> 65"

You have a couple of errors in your formula that the above fixes.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top