Solved

Crystal report formula not working

Posted on 2014-01-01
8
1,089 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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!
Creating and Managing Databases with phpMyAdmin in cPanel.
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…

867 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

17 Experts available now in Live!

Get 1:1 Help Now