简体   繁体   中英

Crystal Reports - Grouping records

I'm trying to group records based on an age range formula where the ranges overlap and it's possible a person will belong to more than one range, my formula looks as follows

   if {@Age} in 55 to 75 then
       "55-75" else
   if {@Age} in 40 to 75 then
       "40-75" else 
   if {@Age} in 18 to 75 then
       "18-75"

My problem is I can't get the people to show up in multiple groups if they belong to more than one.

Simple answer: what you are trying to do won't work. Crystal Reports will place the record in one and only one group.

If you just need to tally values, I would suggest the following:

//{@bucket 01}
if {@Age} in 55 to 75 then
  1
else
  0

//{@bucket 02}
if {@Age} in 40 to 75 then
  1
else
  0

//{@bucket 03}
if {@Age} in 18 to 75 then
  1
else
  0

If you really need to group by age range, you will need to switch to a Command (instead of using the visual-linking 'expert'), then create a UNION query that creates recordsets for each bucket.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM