Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula to Retrieve Last Year Info Post Reply Post New Topic
Author Message
bucky7199
Newbie
Newbie
Avatar

Joined: 17 Feb 2008
Location: United States
Online Status: Offline
Posts: 30
Quote bucky7199 Replybullet Topic: Formula to Retrieve Last Year Info
     Posted: 20 Mar 2008 at 1:44pm
I am writing a comparative financial statement comparing this year to last year this month to last years month. I need to write a formula that will pull this month for last year's data. The table/fields in my database are:
 
GLPerBal.FiscalPeriod = data is an integer, ie 1 = Jan, 2 = Feb etc
GLPerBal.FiscalYear = data is also an integer, 2,007 = 2007 etc
 
I have 2 parameters set up, {? Month}, {? Year}, to select the month and year.
 
This is the best I can come up with so far, and it doesn't work:
 
if {GLPerBal.FiscalYear} = ({? Year}-1)
    and {GLPerBal.FiscalPeriod} = {? Month} then
{GLPerBal.CreditAmt} + {GLPerBal.DebitAmt}
 
I know this is a little complicated, but there are alot of experienced users on this site. Any help would be appreciated.
 
Thanks.
Dan S.
IP IP Logged
bucky7199
Newbie
Newbie
Avatar

Joined: 17 Feb 2008
Location: United States
Online Status: Offline
Posts: 30
Quote bucky7199 Replybullet Posted: 21 Mar 2008 at 1:27pm
I actually answered my own question. Thought I would post it, in case someone else out there has the same problem. This is how I changed my formula:
 
// works BALANCE YEARTODATE LAST YEAR
if {GLPerBal.FiscalYear} = year({?End Date Year}) - 1 then
  if {GLPerBal.FiscalPeriod} <= month({?End Date Year}) then
     {GLPerBal.CreditAmt} + {GLPerBal.DebitAmt}
Dan S.
IP IP Logged
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