Solved

Crystal report formula not working

Posted on 2014-01-01
8
1,054 Views
Last Modified: 2014-01-01
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
formula error
0
Comment
Question by:Gerhardpet
8 Comments
 
LVL 11

Expert Comment

by:Technodweeb
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)) + " " +

Open in new window

0
 
LVL 41

Accepted Solution

by:
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))+" "+

Open in new window

0
 
LVL 6

Expert Comment

by:ButlerTechnology
ID: 39749974
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.
0
 
LVL 11

Expert Comment

by:Technodweeb
ID: 39749977
Yes, you are correct...
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Author Comment

by:Gerhardpet
ID: 39749985
@ButlerTechnology

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

Author Comment

by:Gerhardpet
ID: 39749995
This is what I have now and I get this error
formula error
0
 
LVL 11

Expert Comment

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

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

Author Closing Comment

by:Gerhardpet
ID: 39750099
@Technodweeb
That did not work.

@pcelba
your formula works. Thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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!
Video by: Steve
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…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now