Click here to Skip to main content
15,921,463 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Using Crystal Reports for VS2010.

I have the following requirement for a standalone CR.:

From the indicated start date, retrieve all sales records from the table for the next 12 months. StartDate is the parameter that report uses and user selects.

Columns are as under: Month1 is the month of the StartDate followed by consecutive months.

Column1 Column2 Month1 Month2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
For eg: If StartDate is 01/05/2013 (May 2013) then columns should be:

Column1 Column2 May13 Jun13 Jul13 Aug13 Sep13 Oct13 Nov13 Dec13 Jan14 Feb14 Mar14 Apr14

Would really appreciate if someone could point me to links or give some directions on how to achieve this.


UPDATE:

I have managed to achieve the Dynamic column headers using formula

ToText(DateAdd('m', 1, {?StartDate}), 'MMM yy')
I am stuck figuring out a formula to get the data value in the Detail section. If field name is {Sales.Extension} how do I calculate the Sum of Extension for that Month only.
Posted
Updated 12-Jan-14 13:05pm
v2

The main idea is to use Cross-Tab as is described here[^].

Have a look here: Crystal report with Dynamic Column[^]
 
Share this answer
 
Instead of using Crosstab (so much complicated and I hate it), I used the std formula way.

Created 12 formulae one each month header
@m1: ToText({?StartDate}, 'MMM yy') 
@m2: ToText(DateAdd('m', 1, {?StartDate}), 'MMM yy')

And so on upto 12.

This gives a dynamic header listing the Month names in the Column Headers.

For the data part,

@ext1:
C#
if ToText({SALES_TX_HDR.sale_date}, 'MMM yy') = {@m1} Then
        {SALES_TX_LINES.extension}


@ext2:
C#
if ToText({SALES_TX_HDR.sale_date}, 'MMM yy') = {@m2} Then
        {SALES_TX_LINES.extension}


Ans so on.

Works as I want listing the Sum of sales for an item for that month.

Thanks Guys appreciate it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900