Crystal report formula not working

I have one report where the following formula is not working. I did not design this reports and as far as I know the report should run and look for last months sales history data. Also I'm pretty sure this report worked in 2013 so it may be that the formula does not work in 2014 because of it set to look at last months data.


TOTEXT(IF MONTH(CurrentDate)=1 THEN YEAR(CurrentDate)-1 ELSE YEAR(CurrentDate),0,"")

Open in new window

Here is the error I get
formula error
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gregory MillerGeneral ManagerCommented:
It is actually the Month formula not the Year...
Replace line 1 with this and see what happens:

Open in new window

Above formula returns JANUARY in January but it should return DECEMBER. This should fix it:

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IF MONTH(CurrentDate)=1 

Open in new window

I think you want to make a minor adjustment to Technodweeb's recommendation.

The issue is that the previous month concept of subtracting 1 works great until the you hit January as 1 - 1 = 0.  I hard coded the value for December in the true part of the If statement.
Get Blueprints for Increased Customer Retention

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Gregory MillerGeneral ManagerCommented:
Yes, you are correct...
GerhardpetAuthor Commented:

You formula does it only replace the first line or the whole formula I have?
GerhardpetAuthor Commented:
This is what I have now and I get this error
formula error
Gregory MillerGeneral ManagerCommented:
Replaces only the first line...
as you have done

Remove the last ")" on the 3rd line
GerhardpetAuthor Commented:
That did not work.

your formula works. Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.