Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: String * values Post Reply Post New Topic
Author Message
cbaldwin
Groupie
Groupie


Joined: 09 Apr 2014
Online Status: Offline
Posts: 81
Quote cbaldwin Replybullet Topic: String * values
    Posted: 12 Aug 2014 at 8:55am
I have a string {field} that I would like to be able to group my report detail by.

examples of data in {field}.
DNR_DEF
DNR_MERGE
DNR_REC
CI_NO_DRAW
CI_DIFF_SETUP

I would like to be able to group all of the MANY fields that begin with "DNR" into one group and all of the fields that begin with "CI" into another group etc.

Is there a way that I can say let {field}DNR* ="DNR" and let {field}CI*=CR. And then group by the results of the new formula that I have created.

I don't know how or if I can use a "*" with my string variable?
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 12 Aug 2014 at 9:40am
group formula like

if {field} like "DNR*" then "DNR" else
if {field} like "CI*" then "CI" .....
IP IP Logged
lolly54
Groupie
Groupie
Avatar

Joined: 25 Sep 2011
Online Status: Offline
Posts: 58
Quote lolly54 Replybullet Posted: 27 Aug 2014 at 5:47am
Besides using "like", you can also try... 
 
if {field} startswith "DNR" then "DNR"
else if {field} startswith "CI" then "CI"
IP IP Logged
cbaldwin
Groupie
Groupie


Joined: 09 Apr 2014
Online Status: Offline
Posts: 81
Quote cbaldwin Replybullet Posted: 27 Aug 2014 at 6:30am
Thank you.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Aug 2014 at 4:29am

you may also consider something a little more dynamic if your data set is changing or you have a lot of options for the string field and you always want to group on the characters that precede the first instance of "_"

 
if instr({field},'_')>0 then split({field},'_')[1] else {field}
 
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.035 seconds.