Print Page | Close Window

This Year vs Last Year

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=9653
Printed Date: 02 May 2024 at 5:05am


Topic: This Year vs Last Year
Posted By: delstar
Subject: This Year vs Last Year
Date Posted: 09 Apr 2010 at 11:05am
OK, this is starting to bug me. It sounds like it should be simpler than it is. Basically, I have a number of records with a date field. I have been given a request for a report to have the following layout ('period' should be considered as the last 7 days) :

Item Desc. | Current Period | Current YTD | Last Year Period | Last Year YTD
----------------------------------------------------------------------------------------

Where each row gives the description and counts for each column according to the label.

I can't even get the Current Period to show properly. I tried creating a field with the formula :
{@date}=last7days
That gives me a count, but seperates it into two columns, true and false. I don't even know where to begin with the 'Last Year Period'. Can anyone help?



Replies:
Posted By: DBlank
Date Posted: 09 Apr 2010 at 12:02pm
You can use Running Totals (RT) to do Counts conditionally.
RTs only work in Footers
Group on item desc.
Suppress group header and details
Place the item desc in the group footer
create a RT as "Current period Count"
Field to sumamrize=date field
type=count
evaluate = use a formula
table.datefield in last7days
reset=on group change (group1)
 
Same thing for current year but change your formula to
table.datefield in YearToDate
 
LastYearPeriod
table.datefield in dateserial(year(currentdate)-1,month(currentdate),day(currentdate)-7) to dateserial(year(currentdate)-1,month(currentdate),day(currentdate))
 
Last year ytd as
table.datefield in LastYearYTD


Posted By: delstar
Date Posted: 12 Apr 2010 at 5:17am
Thank you. This is exactly what I needed.



Print Page | Close Window