Solved

# Crystal Reports formula issue

Posted on 2014-11-19
157 Views
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
Question by:spoye

LVL 100

Accepted Solution

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
``````

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

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

mlmcc
0

LVL 34

Expert Comment

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

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

## Featured Post

### Suggested Solutions

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. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…