Print Page | Close Window

Group Sort Order Formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=7639
Printed Date: 02 May 2024 at 8:35pm


Topic: Group Sort Order Formula
Posted By: winegard
Subject: Group Sort Order Formula
Date Posted: 09 Sep 2009 at 2:08pm
I have a parameter called "Report Type" which gives the user the option of selecting to see the data grouped "By Month", "By Week", "By Day", or "By Hour".
 
I would then like to modify the group so that it correctly groups this data based on the user selected parameter.  I have read you can enter a formula and change the sort order, which I have done... but their must be a way to change the date grouping as well. I have found keywords such as "crGCMonthly" in the technical manual but they do not work.
 
Sample formula...
 
If {?Report Type} = "By Month" then
    crAscendingOrder
Else
   crAscendingOrder
 
------------------------------------------------
 
I think it would be something like...
 
If {?Report Type} = "By Month" then
    crGCMonthly
Else
   crGCWeekly
 
 
 
 
Any help would be appreciated.
 
 



Replies:
Posted By: lockwelle
Date Posted: 10 Sep 2009 at 7:13am
If {?Report Type} = "By Month" then
 totext({table.field}, "MM/yyyy")
else
  If {?Report Type}= "By Week" then
   //hmm. not sure
  else
    If {?Report Type} = "By Day" then
     totext({table.field}, "MM/dd/yyyy")
    else //, or "By Hour".
     totext({table.field}, "MM/dd/yyyy HH")
 
this should at least give a start.   make the formula and then in the grouping, choose the formula...poof...all done.  Use this method all the time.
 
HTH


Posted By: winegard
Date Posted: 10 Sep 2009 at 8:43am
Thanks for the help but that formula obviously does not return a value that will be accepted in a Group Sort Order formula.
 
Only work around I've found is to create 4 different groups and 4 different charts and suppress the 3 not selected based on the parameter they choose.
 
It works, just not the best use of computing power. Has to be a way to add in the crGCMonthly.


Posted By: lockwelle
Date Posted: 11 Sep 2009 at 6:37am

you should post what you want.  You said you wanted a dynamic grouping, you said nothing about group sort order formula.  I use the above and variations of it to dynamically group in dozens of reports.

I do not believe in solving your problem in every way, that is what you are getting paid for, but rather to show a path.  Using the above, you could easily format EVERY instance to be mm/dd/yyyy hh, you would just need to think about it, which is again what you are paid to do, as am I.
 
So getting a bit snippy, is I believe a bit out of line.
 


Posted By: winegard
Date Posted: 11 Sep 2009 at 7:07am
Originally posted by lockwelle

you should post what you want.  You said you wanted a dynamic grouping, you said nothing about group sort order formula. 

 
The title of this post is "Group Sort Order Formula".


Posted By: Smittles
Date Posted: 05 Oct 2010 at 6:21am
Nice, guys. Way to bicker about a problem and ruin Google searches about the actual issue.



Print Page | Close Window