Solved

Crystal Reports XI Display 0 for Negative Number

Posted on 2013-12-27
7
1,464 Views
Last Modified: 2013-12-27
Same report as my initial Date Filter question from yesterday... in the attachment you will see I've suppressed the report detail line and am looking at the Sum of TimeTicketDet.ManHrs in GF1 and Sum of OTHrs as the formula @OT...
Sum ({TimeTicketDet.ManHrs}, {TimeTicket.EmplCode})-40

When the Sum of GF1-EmplCode TotalHrs is < 40 the @OT formula is producing a negative number. It's the negative OT value I would liked displayed as 0.

I thought to rewrite @OT as...
if {@OTSumm} < 0 then
0
Else
Sum ({TimeTicketDet.ManHrs}, {TimeTicket.EmplCode})-40

But I get "formula cannot refer to itself, either directly or indirectly"

@OTSumm looks like...
WhilePrintingRecords;
NumberVar OTSumm:=OTSumm  + {@OT};

Which leads me to believe I need to declare a NumberVar for the OTHrs. I feel like I'm mixing summary and running total techniques making it unnecessarily convoluted and complex. There's got to be a more elegant way write this report.

The ultimate goal is to have the report filter for LastFullWeek TimeTicket records by EmplCode; sum total hours and display OT as anything > 40 and anything in the OT column < 40 as 0.
Doc5.pdf
0
Comment
Question by:Lee Ingalls
  • 3
  • 3
7 Comments
 
LVL 18

Expert Comment

by:vasto
ID: 39742036
Did you try to create a new formula :
if {@OTSumm} < 0 then
0
Else
Sum ({TimeTicketDet.ManHrs}, {TimeTicket.EmplCode})-40

and to use it instead of {@OTSumm}  ?
You will still need to place {@OTSumm} on the report in order to calculate the values , but it can be suppressed
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 39742253
Try this for @OT

If Sum ({TimeTicketDet.ManHrs}, {TimeTicket.EmplCode}) < 40 then
  0
Else
   Sum ({TimeTicketDet.ManHrs}, {TimeTicket.EmplCode})-40

Open in new window


mlmcc
0
 
LVL 8

Author Closing Comment

by:Lee Ingalls
ID: 39742449
Thank you mlmcc! While both vasto's and your suggestions worked; I choose yours for the simplicity of the single edit. Felt like I was close; but don't work with Crystal everyday to be sure... repetition is the father of skill!
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 8

Author Comment

by:Lee Ingalls
ID: 39742457
A follow up question is... is this the most efficient way to construct this report?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39742693
Without seeing the actual report and the data it is hard to say.

DOes it run quickly or take several minutes?

mlmcc
0
 
LVL 8

Author Comment

by:Lee Ingalls
ID: 39742714
It's pretty quick... about one second to refresh report data. Refining the question... is summary more efficient than running totals? Does one have benefit over the other?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39742731
They really serve different purposes though the end result is much the same (a summary of the data)

Summary functions are evaluated early in the process so they can appear in a group header or the report header where as running totals are evaluated as the report is printed so the final value is only available in the group footer or report footer

Running totals can be used to show the running total in the detail section but a summary will show the final value.

Running totals provide the ability to determine when they are executed and when they are reset.  Summary functions include all records and are controlled through the 2nd parameter for the group to summarize on.

mlmcc
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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