Solved

Crystal Reports formula issue

Posted on 2014-11-19
3
160 Views
Last Modified: 2014-11-20
I am trying to create a summary that only looks at the past months data.  The query pulls the past 6 months, but I only have a summary for the past month.   I am using a case statement as below...

select (Month({Ens_CustDashReport;1.order_date}))
      case  Month(CurrentDate - 1):
    ((Sum({Ens_CustDashReport;1.On Time shipment})/count({Ens_CustDashReport;1.co_line})) * 100)

   Default : 20

This doesn't work it always looks at the entire collection.  Can anyone help?
0
Comment
Question by:spoye
3 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 40453811
Try a formula like
Name - LastMonthShipped
If ({Ens_CustDashReport;1.order_date} In LastFullMonth then
     {Ens_CustDashReport;1.On Time shipment}
Else
    0

Open in new window


Add another formula
Name - LastMonthCount
If ({Ens_CustDashReport;1.order_date} In LastFullMonth then
    1
Else
    0

Open in new window


Summarize with
Sum(LastMonthShipped) / Sum(LastMonthCount) * 100

Open in new window


mlmcc
0
 
LVL 34

Expert Comment

by:James0628
ID: 40454727
The problem is that CR summary funtions (Sum, Count, etc.) always give you the total for the entire report (or group).  It's not conditional.  For example, if you have a formula like this:

if {field1} = "Y" then
  Sum ({field2})

 Whenever field1 is "Y", you'd get the total for field2 for the entire report.  If field1 is not "Y", you'd get 0.

 You can use formulas like the ones that mlmcc posted to control which records are included in a summary, although the last formula should be:

Sum({@LastMonthShipped}) / Sum({@LastMonthCount}) * 100


 FWIW, I'd probably use formulas like those, but, if you don't need the summaries until the end of the report, running totals would be another option.  You would set the summary and count to be evaluated when the date was in the desired month.

 James
0
 

Author Closing Comment

by:spoye
ID: 40455148
I worked! Thank you very much for the help, and for helping me to learn a bit more.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
A short film showing how OnPage and Connectwise integration works.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

932 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

10 Experts available now in Live!

Get 1:1 Help Now