Calculate Weight By Date

Shared NumberVar WeightRunner;
WeightRunner

I have this formula in crystal report but I need it to calculate the weight by each date, right now when I put this in the group footer it only calculates the weight of the first date….for example
5/1/ - 9,045

I need it to calculate the weight by each date…
5/1 - 9,045
5/4 - 29, 984
TOTAL - 39,029
Jeff SwimsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
How are you grouping?
If it is by the date field do you have it set to group by day or is it doing it by week?

Where are you calculating the weight?

mlmcc
Jeff SwimsAuthor Commented:
How are you grouping?
I’m grouping by a field called ship date.

If it is by the date field do you have it set to group by day or is it doing it by week? It’s grouping by day.

Formulas Used In Report:
@Casting Qty
if ({PROD_Despatched_Items.Service} = 0 and {PROD_Despatched_Items.Container} = 0)
then {PROD_Despatched_Items.Qty}
else 0

@WeightEach
Shared NumberVar PassWeight;
PassWeight := Int({PROD_Despatched_Items.KG_Each} * 2.20462);
PassWeight

@ExtWeight
Shared NumberVar WeightRunner;
NumberVar LineWeight;
LineWeight := {@Casting Qty}*{@WeightEach};
WeightRunner := WeightRunner + LineWeight;
LineWeight

@EndWeight
Shared NumberVar WeightRunner;
WeightRunner
mlmccCommented:
I assume ExtWeight is in the detail section.  The other 2 if they need to be displayed are also in the detail section.

Why are you using SHARED variables?
Are any of the formulas in a subreport?
If not then GLOBAL is sufficient.

mlmcc
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Jeff SwimsAuthor Commented:
I assume ExtWeight is in the detail section.  The other 2 if they need to be displayed are also in the detail section.
Yes all the fields are in the detail section.

Why are you using SHARED variables?
Because the value is not always the same in the database.

Are any of the formulas in a sub report?
No sub reports used in the report…

If not then GLOBAL is sufficient.

My problem is it’s not seeing weight for each day and I don’t know how to make it do that.
mlmccCommented:
Do you have the weight field in the detail section or in the date group footer?

Do you have multiple weights on each day?

mlmcc
Jeff SwimsAuthor Commented:
Do you have the weight field in the detail section or in the date group footer?
Yes, the weight field is in the detail section and in the report footer section.

Do you have multiple weights on each day?
Yes, but I need a sum of each day then a total of all the days.
mlmccCommented:
Can you upload the report file?

mlmcc
James0628Commented:
Do you use any of those variables anywhere else?  If not, then you may not need them at all.

 Assuming that you don't need those variables anywhere else, then, from what I can tell, you could just use a simple summary.

 Create a new formula that contains the following:

if {PROD_Despatched_Items.Service} = 0 and {PROD_Despatched_Items.Container} = 0
then {PROD_Despatched_Items.Qty} * Int ({PROD_Despatched_Items.KG_Each} * 2.20462)
else 0

 Then just do a summary on that formula for the date group, and for the report.  If you don't know, you can put that formula in the detail section temporarily, right-click on it and create your summaries, and then delete the formula from the detail section (it doesn't have to be on the report for the summaries to work).  Of course, if you want to see that value in the detail section, you can leave the formula there.

 For the record, if I'm right about what you're trying to do, then I'm sure that the formulas that you were trying to use (with the variables) could be made to work.  But, as far as I can tell, they're not necessary.


 Also, to address one thing you said earlier ...
 When mlmcc asked why you were using Shared variables, you said "Because the value is not always the same in the database".

 When it comes to using Shared vs Global variables, the values in the db don't matter.  Shared variables allow you to share values between the main report and any subreports.  If you don't have any subreports, then as long as the variables are declared and used properly, the results will be the same whether they're Global or Shared.

 Having said that, there's nothing wrong with using Shared variables in this case.  They're not _necessary_.  Global would work as well.  But I'm not aware of any real reason _not_ to use Shared.  FWIW, I usually use Shared, just because you have to be a bit more careful about how you declare and use Global variables.

 James

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mlmccCommented:
There is one issue with shared variables.  If you use them then those formulas can't be used in summaries because they are automatically put in the printing pass for evaluation.

mlmcc
James0628Commented:
mlmcc,

 You're right, of course (and I even thought of that when I was looking at the OP's formulas).  The OP doesn't appear to have been using those formulas in summaries, so that doesn't seem to be a factor in this case.  But even if it's not, it's certainly worth noting.

 James
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.