Solved

Crystal Reports XI Display 0 for Negative Number

Posted on 2013-12-27
7
1,500 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 101

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
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
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 101

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 101

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

696 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