Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Group some separate and lump all others together Post Reply Post New Topic
Author Message
carstowal
Groupie
Groupie


Joined: 31 Jul 2008
Online Status: Offline
Posts: 80
Quote carstowal Replybullet Topic: Group some separate and lump all others together
     Posted: 18 Jun 2009 at 7:01am
CR9

GH1 = Customer.ID
GH2 = CloseDate by Year

My report works fine, but I would like to Group #1 Customer.ID in such a way that the groups are:
ID = 1004, 1366, 1928, 2045, 2150, and everybody else

This way I see summary data for certain accounts and lump everybody else into one summary.

Can this be done in one report?  
(Otherwise I would have to run a report for the certain accounts and then run a report excluding them.)

(The customers I want to see are not necessarily the high volume accounts so using the top N isn't an option.)
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Jun 2009 at 7:18am
create a formula to do this and then group on the formula (assuming your customer id is numeric)...
 
if {customer.id} in [1004, 1366, 1928, 2045, 2150] then totext({customer.id},0,"") else "Everybody else"


Edited by DBlank - 18 Jun 2009 at 7:19am
IP IP Logged
carstowal
Groupie
Groupie


Joined: 31 Jul 2008
Online Status: Offline
Posts: 80
Quote carstowal Replybullet Posted: 18 Jun 2009 at 8:23am
at the end of "everybody else" I get an error

"a string is required here"

The Customer.ID are all numbers but the data type is varchar
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Jun 2009 at 8:29am
if {customer.id} in ["1004", "1366", "1928", "2045", "2150"] then {customer.id} else "Everybody else"
IP IP Logged
carstowal
Groupie
Groupie


Joined: 31 Jul 2008
Online Status: Offline
Posts: 80
Quote carstowal Replybullet Posted: 18 Jun 2009 at 10:07am
now the error message is
 
"the result of selection formula must be a boolean"
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Jun 2009 at 10:35am

This formula is not to be used in the select expert (select statement). It is to be used as a new formula field. From there you group on the formula field rather then the original customer id field.

Basically what we are trying to do here is create a piece of data that meets your needs from the already existing data. You indicated that you wanted all of the records to still in the report and therefore you cannoty use the select expert which only ,manages what items are included or excluded, not how they are grouped or sorted.
In the Field explorer, right click on the Formula Fields and select NEW.
Give it a name like "Grouping".
Put the formula from above in it, save and close it.
Place this formula field on your details row next to the original customerid field and preview the report.
It should now have converted all the "other" records into the verbage "Everybody Else" and left the "1004", "1366", "1928", "2045", "2150" ones as is.
Now if you group on this new formula field it sticks all the like items together giving you 6 groupings ... "1004", "1366", "1928", "2045", "2150", "Everybody Else" which is what you wanted.
Note that you can change the wording of "Everybody Else" to something more professional by altering your formula (see red ink below). Your grouping will automatically change when the formula changes...
if {customer.id} in ["1004", "1366", "1928", "2045", "2150"] then {customer.id} else "Other Customers"
 
You can also remove the formula field from the details row. You don't need it there to group on it. I just put it in there so you can see what it is doing.


Edited by DBlank - 18 Jun 2009 at 10:37am
IP IP Logged
carstowal
Groupie
Groupie


Joined: 31 Jul 2008
Online Status: Offline
Posts: 80
Quote carstowal Replybullet Posted: 18 Jun 2009 at 11:51am
THANK YOU

it works perfectly!
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum