Solved

Crystal Reports formula issue

Posted on 2014-11-19
3
161 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

772 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