Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Summarize Current Year vs Last Year by month Post Reply Post New Topic
Page  of 2 Next >>
Author Message
chudok
Groupie
Groupie


Joined: 18 May 2010
Online Status: Offline
Posts: 70
Quote chudok Replybullet Topic: Summarize Current Year vs Last Year by month
    Posted: 21 Apr 2014 at 7:05am
I am trying to have a user enter in a date parameter.  they will enter in for a 2 year range.  I am trying to return data into (CY Jan, LY Jan), (CY Feb, LY Feb) etc....

When i break out the dates by month and year it won't let me summarize or get a running total for each month.

I cannot figure out how to get this to work and give me a total for each month.
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 21 Apr 2014 at 7:31am
I am not sure if is this what you want, but you can create a formula like below for each month and then do the summary
if {TABLE.DATE} >= dateSerial ((Year (CurrentDate)),(Month (CurrentDate)) ,Day (Minimum (LastFullMonth))) and
{TABLE.DATE} <= dateserial(year(currentdate),month(currentdate),1-1)
then {Field to be summarized} else 0
this one will returns previews month data

Edited by otto - 21 Apr 2014 at 7:33am
IP IP Logged
chudok
Groupie
Groupie


Joined: 18 May 2010
Online Status: Offline
Posts: 70
Quote chudok Replybullet Posted: 21 Apr 2014 at 8:10am
if {GL_DetailPosting.PostingDate}>=Date(year(minimum({?Date Range}))+1,Month(minimum({?Date Range})),2) and
  {GL_DetailPosting.PostingDate}<=maximum({?Date Range})  and month({GL_DetailPosting.PostingDate})= 1 then {@Amount}



this is working for my current year data, I just can't figure out the formula to get last years data by month......
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 21 Apr 2014 at 8:46am
I am not sure if this one is the best way, but is the way that I did it once in a 13 month trend report I had to do. I created @EndDate(Maximum{?Date Range}) and @StartDate(Minimum{?Date Range}) formulas that storage Maximum and Minimum date range of my date parameter. Then I created 13 formulas, one per month with this format and placed on details section.

this will capture your last month(@EndDate)
you can call this formula Month24 b/c you will need 24 month of data, right?
if {GL_DetailPosting.PostingDate} >= DateSerial ((Year ({@End_date})),(Month ({@End_date})) ,Day (Minimum (LastFullMonth))) and
{GL_DetailPosting.PostingDate} <= {@End_date}
then {@Amount} else 0

Next you will have to create another formula @Month23
if {GL_DetailPosting.PostingDate} >= DateSerial ((Year ({@End_date})),(Month ({@End_date})-1) ,Day (Minimum (LastFullMonth))) and
{GL_DetailPosting.PostingDate} <= dateserial (year({@End_date}),month({@End_date}),1-1)
then {@Amount} else 0

Then another @Month22
if {GL_DetailPosting.PostingDate} >= DateSerial ((Year ({@End_date})),(Month ({@End_date})-2) ,Day (Minimum (LastFullMonth))) and
{GL_DetailPosting.PostingDate} <= dateserial (year({@End_date}),month({@End_date})-1,1-1)
then {@Amount} else 0

and the same with other month so the last one will be

if {GL_DetailPosting.PostingDate} >= DateSerial ((Year ({@End_date})),(Month ({@End_date})-24) ,Day (Minimum (LastFullMonth))) and
{GL_DetailPosting.PostingDate} <= dateserial (year({@End_date}),month({@End_date})-23,1-1)
then {@Amount} else 0

That will capture your amount by month

Edited by otto - 21 Apr 2014 at 8:46am
IP IP Logged
chudok
Groupie
Groupie


Joined: 18 May 2010
Online Status: Offline
Posts: 70
Quote chudok Replybullet Posted: 21 Apr 2014 at 8:50am
These formulas won't let me return a sum total.  that is where I keep falling into issues...


Edited by chudok - 21 Apr 2014 at 8:52am
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 21 Apr 2014 at 9:00am
do you need the whole year summarized in one formula or split it by month to compare it with a year before?
IP IP Logged
chudok
Groupie
Groupie


Joined: 18 May 2010
Online Status: Offline
Posts: 70
Quote chudok Replybullet Posted: 21 Apr 2014 at 9:10am
I need to summarize each month and compare current month-to-date to prior-month-to-date.  
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 21 Apr 2014 at 9:15am
are you grouping on the report?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Apr 2014 at 9:17am
IMO just group on the month and then the year inside the month
datepart('m',GL_DetailPosting.PostingDate)
datepart('yyyy',GL_DetailPosting.PostingDate)
You can then do a sum at the year footer or use a crosstab using these two fields.
if you just want 12 parenthesized values in the report footer just create 24 running totals (the crosstab is much easier) with different evaluation formula.
Jan last year eval criteria
datepart('m',GL_DetailPosting.PostingDate)=1 and
datepart('yyyy',GL_DetailPosting.PostingDate)= year(currentdate)-1
Jan this year
datepart('m',GL_DetailPosting.PostingDate)=1 and
datepart('yyyy',GL_DetailPosting.PostingDate)= year(currentdate)

Edited by DBlank - 21 Apr 2014 at 9:18am
IP IP Logged
chudok
Groupie
Groupie


Joined: 18 May 2010
Online Status: Offline
Posts: 70
Quote chudok Replybullet Posted: 22 Apr 2014 at 2:09am
I don't necessarily need current year for my report.  they be comparing and looking back to the 2 prior years.... so how can i incorporate the year from a Parameter field?

This works for my current year - but for PY I can't get a formula to work and to summarize...... any thoughts?

if {GL_DetailPosting.PostingDate}>=Date(year(minimum({?Date Range}))+1,Month(minimum({?Date Range})),01) and
  {GL_DetailPosting.PostingDate}<=maximum({?Date Range})  and month({GL_DetailPosting.PostingDate})= 1 then {@Amount}


Edited by chudok - 22 Apr 2014 at 2:11am
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.029 seconds.