Link to home
Start Free TrialLog in
Avatar of Gerhardpet
GerhardpetFlag for Canada

asked on

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.

UPPERCASE(MONTHNAME(MONTH(CurrentDate)-1,FALSE))+" "+

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

Open in new window


Here is the error I get
User generated image
Avatar of Gregory Miller
Gregory Miller
Flag of United States of America image

It is actually the Month formula not the Year...
Replace line 1 with this and see what happens:
IF MONTH(CurrentDate)=1 THEN UPPERCASE(MONTHNAME(MONTH(CurrentDate),FALSE)) ELSE UPPERCASE(MONTHNAME(MONTH(CurrentDate)-1,FALSE)) + " " +

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ButlerTechnology
ButlerTechnology

IF MONTH(CurrentDate)=1 
THEN UPPERCASE(MONTHNAME(12),FALSE)) 
ELSE UPPERCASE(MONTHNAME(MONTH(CurrentDate)-1,FALSE)) + " " +

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.
Yes, you are correct...
Avatar of Gerhardpet

ASKER

@ButlerTechnology

You formula does it only replace the first line or the whole formula I have?
This is what I have now and I get this error
User generated image
Replaces only the first line...
as you have done

Remove the last ")" on the 3rd line
@Technodweeb
That did not work.

@pcelba
your formula works. Thanks!