Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding month column heading when there is no data

Status
Not open for further replies.

Chuck712

Technical User
Mar 1, 2002
133
US
I have a report that counts and sums source codes from membership applications, by chapter. The query is a stored procedure from an SQL server. The result set is fine, but in the report I am getting these results:
Jan Feb Mar May
SourceA 1 3 1 0
SourceB 0 0 1 0
SourceC 2 0 0 1
SourceD 2 1 0 0

What I am trying to get is:
Jan Feb Mar Apr May
SourceA 1 3 1 0 0
SourceB 0 0 1 0 0
SourceC 2 0 0 0 1
SourceD 2 1 0 0 0

In other words a 0 column if no applications were sent in for that month. I really don't want to add a temp table to the SP, and that would require some huge "corporate" involvement. Does anyone have a tip on how I might accomplish this within the report itself?
I am not much of a report writer.
 
I would suggest correcting the SP to always return blank values for months that don't have values.

One workaround is to create formulas for each month in Crystal, as in:

Group by the Source.

Place this formula in the group header:

whileprintingrecords;
numbervar jan:=0;
numbervar feb:=0;
numbervar mar:=0;
numbervar apr:=0;
...etc... allmonths

Place these formulas in the details:

whileprintingrecords;
numbervar Jan;
if month({table.date} = 1 then
jan := jan+{table.qty}

whileprintingrecords;
numbervar Feb;
if month({table.date} = 2 then
Feb := Feb+{table.qty}

... through the december (month =12) ...

Now suppress the group header and details and display the results in the groupfooter alongside each other:

whileprintingrecords;
numbervar Jan

whileprintingrecords;
numbervar Feb

etc...

-k
 
Thanks so much. This is a great start. I should have mentioned that this was a cross tab report with the months as the column headings and the source code as the rows with the counts in the columns. I am having a little trouble making this work with the cross tab. Any suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top