CraigBob
CraigBob

Reputation: 157

Crystal reports Crosstab date grouping.

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've see something like this:

Previous Jan Feb Mar Apr May Jun Jul

Is there a way of doing this in CR XI?

Upvotes: 0

Views: 4804

Answers (2)

CraigBob
CraigBob

Reputation: 157

The answer was actually a modification of Lee's answer.

if {Command.ReqDate} < date(year({?StartDate}),month({?StartDate}),1) then dateadd('m',-1,{?StartDate}) else {Command.ReqDate}

use this to group on in the CT set to monthly
right click on the column header
select Format field,
select common tab
select display string formula
if currentfieldvalue < date(year({?StartDate}),month({?StartDate}),1) then 'previous' 
else totext(currentfieldvalue,'MMM')

Upvotes: 0

Lee Tickett
Lee Tickett

Reputation: 6027

You would have to create a formula to do this (or probably two formulas one to get them in the correct order and another to display the correct string):

grouping formula: if {table.datefield} < currentdate then '0000' else cStr({table.datefield}, 'yyMM')

display formula: if {table.datefield} < currentdate then 'Previous' else cStr({table.datefield}, 'MMM')

ADDED SCREENSHOT

enter image description here

enter image description here

Upvotes: 1

Related Questions