Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula Question Post Reply Post New Topic
Author Message
rpotts1973
Newbie
Newbie


Joined: 04 Sep 2012
Online Status: Offline
Posts: 4
Quote rpotts1973 Replybullet Topic: Formula Question
     Posted: 04 Sep 2012 at 12:54am

Looking for some help on a formula, to accomplish the below needs.

1.       Only need to group based on first 3 characters.

2.       Based on first 3 characters, group into proper region.

3.       If third character is a letter (K) put into special group.

4.       Only display first 2 characters in the report.

 

Data grouping Example:

Region: West = 110 through 269…

Region: South = 310 through 489…

Region: Special = 25K through 67K

Data Set Examples:

1101

1205

1405

2590

25K1

2601

26K2

3501

3105

32K1

3602

4801

4810

6509

65K1

6701

 

 

Thanks,


Ryan

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 04 Sep 2012 at 4:25am
make a formula that returns values that work for you....
basically make a formula with the criteria and have it return the value of the regions. When it does that correctly, make the formula the grouping criteria.
 
HTH
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 04 Sep 2012 at 4:33am
Here's what I would do:
 
1.  Create a formula to get the first three characters (I'll call this {@RegionNo}) -
 
Left({MyTable.MyField}, 3)
 
2.  Create another formula to get the actual region:
 
Switch(
  {@RegionNo} >= '110' and {@RegionNo} <= '269', 'West',
  {@RegionNo} >= '310' and {@RegionNo} <= '489', 'South',
  {@RegionNo} >= '25K' and {@RegionNo} >= '67K', 'Special',
  true, 'Unknown')
 
Use this formula as your group.
 
3.  Use the Left() function in a third formula to get just the first two characters for your display.
 
-Dell
 
 
IP IP Logged
rpotts1973
Newbie
Newbie


Joined: 04 Sep 2012
Online Status: Offline
Posts: 4
Quote rpotts1973 Replybullet Posted: 04 Sep 2012 at 5:03am
This is what I was looking for as I didnt know how to apply it to a specific region.
Switch(
{@RegionNo} >= '110' and {@RegionNo} <= '269', 'West',
{@RegionNo} >= '310' and {@RegionNo} <= '489', 'South',
{@RegionNo} >= '25K' and {@RegionNo} >= '67K', 'Special',
true, 'Unknown')
 
Thank you!
 
Ryan


Edited by rpotts1973 - 04 Sep 2012 at 5:48am
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