How to group in Crystal Reports a field with contained values of 5's

Carlo Vasquez
Carlo Vasquez used Ask the Experts™
on
I want to be able to group the unitCost value by increments of amount value in 5 in Crystal Reports 2008.
How is this accomplished?


Example:

Group 1
Item ID      Unitcost
AB123        1
AB124         2
AB125        3
AB126        5

Group 2
Item ID      Unitcost
CD123      6
CD124      6
CD125      7
CD126      10

Group 3
Item ID      Unitcost
CE123       11
CD124      12
CD127      14
CD128     15

Please help. Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Add a formula like this and group on it

whilereadingrecords;
global numbervar myrecnum;
myrecnum:= myrecnum + 1;
myrecnum \ 5

Open in new window


The first group will only have 4 records but after that they should have 5
mlmcc

Author

Commented:
mlmcc, I apologize I wrote it wrong....
I want the values in that field, unitCost, to be group by increments of every 5 dollar amounts.

So everything that has a value in UnitCost from 0 to 5 I Want it grouped.
Then everything from 6 to 10 I want it groups and so on...incremental values of 5 in the field.

Your answer was good though.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Try this formula

{Value Field} \ 5

Open in new window

Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Author

Commented:
Good call though but that didn't go to well since I have values of 0.00.
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet Software

Commented:
If you wish to call Group 0 Group 1, just add 1 to the expression mlmcc provided.
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
If you have to have 0-5, 6-10

Try it this way

If ({ValueField} <= 5) then
    1
else If ({ValueField} <= 10) then
    2
else If ({ValueField} <= 15) then
    3
etc

Open in new window


You change it to

If ({ValueField} <= 5) then
    "0-5"
else If ({ValueField} <= 10) then
    "6-10"
else If ({ValueField} <= 15) then
    "11-15"
etc

Open in new window

Author

Commented:
Thanks mlmcc all I had to do then was group the report by that formula!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial