IF {@SiteType} = "BUILDING A" THEN 100 ELSE
IF {@SiteType} = "AREA 5" THEN 200 ELSE
IF {@SiteType} = "SECTION 67" THEN 300 ELSE
IF {@SiteType} = "AILSE 2" THEN 400 ELSE
IF {@SiteType} = "SHELF 100" THEN 500 ELSE
I use the 000 number format so if there is a new {@SiteType} that is later added, it can easily be inserted without a lot of rework.
Hope this helps!
FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
Not sure that the second solution will work with groups, but Firegeek's formula will work. However, if my formula isn't working then there would almost have to be some null values, in which case Firegeek's formula would need some catchall value in the else clause to work - ELSE 9999 for instance.
Or, working with briangriffin's approach, amend the formula to customise the group name to:
Code:
If Not Isnull({@SiteType})
Then Mid({@SiteType},2)
Note, with the [Bold]Mid[/Bold] function it is not necessary to include the length of the string. Everything from the starting point onward is the default.
Went with briangriffin's and pmax9999's update, but am definitely keeping all these notes handy, as I know I'll be using them in the future. Really helpful.
As briangriffin noted, this approach only works with less than 10 values. It can be amended to cater for more, by using a prefix of 01, 02, 03 etc [and a customsed group formula of: If Not Isnull({@SiteType}) Then Mid({@SiteType},3)] to work with up to 99 records, and just add additional leading zeros if more capacity is required.
The reason it is necessary to pad with leading zeros is to preserve the sort order when the numbers become strings (otherwise the sort order would become 1, 10, 11, 12, ... 2, 20, 21 when sorted alphabetically)
Im really confused by this thread for some reason....
Forgive me for dragging this one on but I frequently have the scenario which requires me to order my groups in a specific order so I am interested.
Am I correct in assuming brians formula and pmax subsequent modifications are for modifying the group name after appending the numeric digits? I am curious to see the formula used to add those digits. I am picturing an If Then as Firegeek mentioned or a select case as I offered. The reason I create a separate formula to group/sort on is because I may need @SiteType (ex.) somewhere else in the report where as I would have to create a formula like Brians anyway to display it correctly.
Just curious .. Thanks
_____________________________________ Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection
One other thought ... and please forgive me if I am just so far off the point of this thread that I am annoying folks ...
IF you only have 5 possible results for @SiteType (which is what I read intitially) ...
couldnt you use in group expert - options - in the common tab .. select specified order and order your groups that way? A drop down appears with possible results of @SiteType...
Again... not sure why I am having problems following this thread except that I have this requirement often..
_____________________________________ Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection
COSpringsGuy - you're exactly right, you could do this one with Specified Groups. However, I personally find that to be kind of a pain so I generally write a formula, group on the formula, and then modify the group display name if needed. It's a much more scalable approach, but mostly personal preference. As you know, in Crystal there are always at least three ways to do everything.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.