Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Crystal reports Crosstab date grouping Post Reply Post New Topic
Author Message
Craigbob
Newbie
Newbie


Joined: 21 Aug 2012
Location: United States
Online Status: Offline
Posts: 27
Quote Craigbob Replybullet Topic: Crystal reports Crosstab date grouping
     Posted: 18 Jan 2013 at 11:24am
I'm adding this forum as I've gotten no responses to the question in the Report Design forum. Sorry for the multiple post.

I've created a report using the crosstab control which groups the data by date in columns. I'd like to take all of the dates that are earlier than the 1st of the current month (when the report is run) and combine them and the data being summarized into one column called Previous.

So instead of seeing something like this:

Oct Nov Dec Jan Feb Mar Apr May Jun Jul

I want to see something like this:

Previous Jan Feb Mar Apr May Jun Jul

I've tried the following things:

I've created a formula field called grpSort

if {Command.ReqDate} < {?StartDate} then '0000' else cStr({Command.ReqDate}, 'yyMM')

to sort the data and put that in the column area of the crosstab expert.

Then I created a the following formula:

if {Command.ReqDate} < {?StartDate} then 'Previous' else cStr({Command.ReqDate}, 'MMM')

and put that in the Options area of the group options in the Use formula as Group Name formula.

The data sorts correctly, but I never see the Previous column. What am I doing wrong?


Edited by Craigbob - 18 Jan 2013 at 11:25am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Jan 2013 at 4:10am
i would simplify this a bit by just altering the date of any record you want in the previous category as one month ago today , then you can group on the field by month and alter the header to show as you want.
 
if {Command.ReqDate} < date(year(currentdate),month(currentdate),1) then dateadd('m',-1,currentdate) else {Command.ReqDate}
 
use rhis to group on in the CT set to monthly
rigt click on the column header
select Format field,
select common tab
select display string formula
if currentfieldvalue< date(year(currentdate),month(currentdate),1) then 'previous'
else totext(currentfieldvalue,'MMM')
IP IP Logged
Craigbob
Newbie
Newbie


Joined: 21 Aug 2012
Location: United States
Online Status: Offline
Posts: 27
Quote Craigbob Replybullet Posted: 29 Jan 2013 at 6:49am
DBlank,

That worked great. I made one change to use {?StartDate} rather than currentdate. But it did the trick.

Thanks
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