cancel
Showing results for 
Search instead for 
Did you mean: 

Month By month By Year comparison

Former Member
0 Kudos

Post Author: nick7777

CA Forum: Formula

I am a novice Crystal User attempting to compare data by month and year. The data is stored by date (mm/dd/yyyy) and I would like to compare Jan 2005 with Jan 2006 and Jan 2007 then Feb 2005 with Feb 2006 and Feb 2007etc... in a bar chart

Many thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Post Author: DesertRecluse

CA Forum: Formula

Sorry; that should be using DATEPART for the ORDER BY so that the integer data is sorted - otherwise the months will be sorted alphabetically. You would use the DATENAME function to create the concatenated field of January 2005.

Former Member
0 Kudos

Post Author: DesertRecluse

CA Forum: Formula

Create 2 formulas that get the datename for month and year. Create a third formula that concatenates the two. Your result would be January 2005, January 2006, February 2005 and so on. Then put the first 2 formulas in the report where you can sort them - you can hide them and that way you won't see them but the data will sort on them. If you sort by month, year you will get all the January data together (Jan 2005, Jan 2006, Jan 2007...) and then all the February data.

I would do this in the SQL along with the sorting instead of Crystal but you can do it in either. In the SQL you could create a single field in the select statement to use in the report but in the Order By clause you could do something like:

ORDER BY DATENAME(month, StartDate), DATENAME(year, StartDate)