Solved

Crystal report formula not working

Posted on 2014-01-01
1,054 Views
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,"")

Here is the error I get
0
Question by:Gerhardpet

LVL 11

Expert Comment

ID: 39749942
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)) + " " +
0

LVL 41

Accepted Solution

pcelba earned 500 total points
ID: 39749972
Above formula returns JANUARY in January but it should return DECEMBER. This should fix it:
UPPERCASE(MONTHNAME(IF MONTH(CurrentDate)=1 THEN 12 ELSE MONTH(CurrentDate)-1,FALSE))+" "+
0

LVL 6

Expert Comment

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

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.
0

LVL 11

Expert Comment

ID: 39749977
Yes, you are correct...
0

LVL 1

Author Comment

ID: 39749985
@ButlerTechnology

You formula does it only replace the first line or the whole formula I have?
0

LVL 1

Author Comment

ID: 39749995
This is what I have now and I get this error
0

LVL 11

Expert Comment

ID: 39749996
Replaces only the first line...
as you have done

Remove the last ")" on the 3rd line
0

LVL 1

Author Closing Comment

ID: 39750099
@Technodweeb
That did not work.

@pcelba
0

Featured Post

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…