Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula/Grouping Help Post Reply Post New Topic
Author Message
Rome
Newbie
Newbie


Joined: 10 Nov 2009
Online Status: Offline
Posts: 4
Quote Rome Replybullet Topic: Formula/Grouping Help
     Posted: 10 Nov 2009 at 12:30pm
Guys/Gals,
 
I am new here and do not typically create Crystal Reports but here I am.
 
My question is how can I do a group by on essentially a %like% statement?
 
Below is a mockup of my data.
 
Vanoork
**Pen
**Pen
Vanoork
**Pen Ltd
Blank
Example
 
 
I want to group anything with Pen in it and I want to group Blank and Example into their own seperate group.  Everything else then would go into a seperate group.  I would have three groups, one for Pen, one for Blank and Example, and then the last one as a catch-all.  Any ideas?  Thanks
 
 


Edited by Rome - 10 Nov 2009 at 12:30pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Nov 2009 at 12:49pm
Create a formula field and then group on it as:
 
if {table.field} in ["Blank","Example"] then {table.field} else
if instr({table.field},"Pen")>0 then "Pen" else "Other"
IP IP Logged
Rome
Newbie
Newbie


Joined: 10 Nov 2009
Online Status: Offline
Posts: 4
Quote Rome Replybullet Posted: 10 Nov 2009 at 1:08pm

Thank you, that got me much closer to my end goal.  Is it possible to have Blank and Example be under the same grouping? So when I click Blank I see Blank and Example?

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Nov 2009 at 1:10pm
if {table.field} in ["Blank","Example"] then "Blank & Example" else
if instr({table.field},"Pen")>0 then "Pen" else "Other"
IP IP Logged
Rome
Newbie
Newbie


Joined: 10 Nov 2009
Online Status: Offline
Posts: 4
Quote Rome Replybullet Posted: 10 Nov 2009 at 1:23pm
DBlank, you are a very intelligent person. Thank you very much. I do have one more question though.  I have Pen entries still going into my Other filter.  For some reason, they are not going into the Pen filter. Any ideas?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Nov 2009 at 1:29pm
is it missing it if it is 'pen' instead of 'Pen'.
The version I gave was using a case sensitive instring (instr). You can alter it to be case insensitive:
if {table.field} in ["Blank","Example"] then "Blank & Example" else
if instr({table.field},"Pen",1)>0 then "Pen" else "Other"
 
Does that fix it?
IP IP Logged
Rome
Newbie
Newbie


Joined: 10 Nov 2009
Online Status: Offline
Posts: 4
Quote Rome Replybullet Posted: 10 Nov 2009 at 1:44pm
GENIOUS! Thank you very much.
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