Solved

Crystal Report Group Footer Equation

Posted on 2011-09-02
6
301 Views
Last Modified: 2012-05-12
I am trying to get an equation based off the following equations:

Quantity Scrap: Sum ({LaborDistribution.QuantityScrapped},{LaborDistribution.WONumber} )
Cost Analysis Ratio: ({WOHeader.QuantityReleased}/(({@Actual Time Seconds}/60*41.58)/60))
Material Cost: {PartMaster.MaterialCost}
Total Time of scrap: Shared NumberVar scrapped_time;
whileprintingrecords;

numberVar dur := if {LaborDistribution.StartDate} <= Maximum ({@scrapped_time}) then
  scrapped_time := scrapped_time + DateDiff ("n", {LaborDistribution.StartDate}, {LaborDistribution.StopDate});
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

hrs := Truncate(Truncate(dur/60)/60);
min := Remainder(Truncate(dur/60),60);
sec := Remainder(dur,60);

hhmmss := totext(hrs,"0") + ":" + totext(min,"00") + ":"+ totext(sec,"00");



When I try and make this equation: Cost Analysis ratio + (Material Cost / Quatity Scrap) + Total Group Time Scrap


When I try this equation out it give me nothing but a blank screen ???
0
Comment
Question by:cmdolcet
  • 2
  • 2
  • 2
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 36475520
Can any of the fields be NULL?
You are subtracting in Minutes then treating it as seconds

whileprintingrecords;
numbervar scrapped_time;
numberVar dur;
if {LaborDistribution.StartDate} <= Maximum ({@scrapped_time}) then
  scrapped_time := scrapped_time + DateDiff ("s", {LaborDistribution.StartDate}, {LaborDistribution.StopDate});
dur := scrapped_time;
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

hrs := dur \ 3600;
min := Remainder(dur,3600) \ 60;
sec := Remainder(dur,60);

hhmmss := totext(hrs,"0") + ":" + totext(min,"00") + ":"+ totext(sec,"00");

mlmcc
0
 

Author Comment

by:cmdolcet
ID: 36475611
no none of my fields can be Null
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36476276
Did you try my new formula?

mlmcc
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:cmdolcet
ID: 36488301
In order for your equation to work I needed to add the if {LaborDistribution.StartDate} <= Maximum ({@scrapped_time}, {LaborDistribution.WONumber}) then

LabourDistribution.WONumber field.

However even with this formula in here it give me the following (see screen shot) It should add up all the time to the last scrap and after the last scrap all scrap time should be 0:00

Again this equation was placed in my details section

However in the original question I asked why I can;t use the result from the calculation for my
screen-shot.png
0
 
LVL 34

Accepted Solution

by:
James0628 earned 250 total points
ID: 36509425
First of all, just a tip.  If you look at your previous question, where we were working on that formula, there should be an "ask a related question" link/button.  You could use that to start a new question that has a link to the old one, so that people could easily refer back to the previous question if they wanted more background or to check something.

 I can't remember if you were using a group on the report or not.  If you have groups of records, like for different work orders, then Maximum ({@scrapped_time}) should probably be Maximum ({@scrapped_time}, {your group field}).

 That question aside, I think I see the reason that you're not getting 0's.  Going back to your formula in your first post, you have:

numberVar dur := if {LaborDistribution.StartDate} <= Maximum ({@scrapped_time}) then
  scrapped_time := scrapped_time + DateDiff ("n", {LaborDistribution.StartDate}, {LaborDistribution.StopDate});


 Variables default to Global, which means that they keep their values throughout the report.  So, dur is global, and when your formula doesn't set it (because the start date is after the last scrapped date), you just get the last value that was put in dur, so you get 20:04:45 repeated on each line.

 Try changing "numberVar dur" to "Local numberVar dur" (without the quotes, of course).  A local variable is re-created whenever the formula is evaluated, so if you don't set it to something else, it will be 0.

 James
0
 
LVL 34

Expert Comment

by:James0628
ID: 36509431
Oh, yeah.  Don't forget to change the "n" in the DateDiff to "s", as mlmcc mentioned.

 James
0

Featured Post

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.

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. …
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 …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

861 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