Solved

Crystal Reports formula issue

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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