cancel
Showing results for 
Search instead for 
Did you mean: 

CrossTab in CR based on a Date

Former Member
0 Kudos

Hi,

I've been searchin in several forums for the solution of this in CR but no success.

I use SAP Crystal Report V.14 and SS2012, my task is to build a report/pivot with CR for the last 12 months.


artnrcustomercustnostatusLastResponse
10007cust12544St120150824
33139cust25173St120150801
33139cust3667St320150717
11764cust41746St420150901


Output this crosstab in CR:


091011120102030405060708
St12
St31


rows: status
columns: the LAST 12 months (today = 2015-09-03), derived from column LastResponse
pivot: count

As I'm new to CR has anyone a hint for me? thx

Accepted Solutions (0)

Answers (1)

Answers (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Stefan,

If the 'Last Response' is a 'Date' type column, you can try this:

1) Insert a Crosstab. Use Status as the 'Row' and use Last Response as the column. For the Column, click 'Group Options' > Where it says 'Print this date', select 'For each month' from the drop-down.

2) Use any field as the summary and set it to 'Count'.

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

unfortunately the column LastResponse is string and so the dropdown can't present any month data. And I always want to present the LAST 12 months - means a fixed number of columns for the crosstab.

What's the trick? Is it possible at all in CR or better to do a pivot sql on the DB?

thx

abhilash_kumar
Active Contributor
0 Kudos

The LastResponse field can be converted to date using the formula below:

cDate(Picture({LastResponse}, 'xxxx/xx/xx'))

You should now be able to use this formula field as the column and set it to print 'For Each Month'.

If there are 'missing months' in the column, you would need to build a 'Look-up' table consiting of all dates and then replace all references to the date field from the 'old' table with the date field from the 'new look-up table'.

E.g:

-Abhilash

Former Member
0 Kudos

hi,

the table column "LastResponse" now has only valid dates like "20150119" (YYYYMMDD)

cDate(Picture({LastResponse}, 'xxxx/xx/xx'))

I get an error like

"erronous string for date format" and the report leaves blank.

Is the picture not ok?

>>>>>>>>>>>>>>

it was a CR-bug; close and reopen the report and it worked

>>>>>>>>>>>>>>

The look-up-table solution is the most feasable way I think. I try tomorrow...

Former Member
0 Kudos

Hi Abhilash,

thx for your suggestion with the lookup-Table. In T-SQL I could create one and it works like a charm

The result table is used for a CR-subreport and it works very well.


When trying to use the subreport in a mainreport I have one issue: displaying the sub in the main it only shows columns with an entry (not null), in the above example column (= month) 07 and 08 for status St1 and St3, and the status field is the linking field main report to sub.

Any hints?