Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Crystal Report Group Footer Equation

Posted on 2011-09-02
6
Medium Priority
?
305 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
[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
  • 2
  • 2
  • 2
6 Comments
 
LVL 101

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 101

Expert Comment

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

mlmcc
0
[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

 

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 35

Accepted Solution

by:
James0628 earned 1000 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 35

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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 …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 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