Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CRXI - sum formula result from sub group not allowed?

Status
Not open for further replies.

mgason

Technical User
Feb 6, 2003
158
0
0
AU
Hi,
I have data that is grouped.
Batch_Ids are grouped by recipe.
inside that group timestamps are grouped by Batch_ID.

I have a formula which gets the number of seconds between the first and last timestamp for each batch_ID group. It is displayed in the batch_ID group header.

this is the formula
Code:
whileprintingrecords;

dateTimeVar  x:= Minimum
({Mixed_Material_Weighments.tstamp},{Mixed_Material_BatchRef.Batch_ID});
dateTimeVar  y:= Maximum
({Mixed_Material_Weighments.tstamp},{Mixed_Material_BatchRef.Batch_ID});

numberVar totalSeconds:=DateDiff ("s",x ,y);

Now in the Recipe group header I wish to display the sum of the formula results from the batch_Id subgroup.
Does that make sense?

Crystal will not let me insert a sum on the formula?

I can not just use the same datediff formula for max and min timestamp by conditional field recipe as there is dead time between batches I do not wish to count.

thanks
mark
 
create your own formulas like

set totalseconds := 0 in group header
in details section add the seconds totalseconds := totalseconds + batchidtotalseconds

in group footer show the value of totalseoncds...

basically you are setting one running total by your formulas
 
Hi,
we are not quite understanding your solution I think.
we tried but could not get it to work.

I am going to make a better attempt at an explanation of our data just to be sure.

Group1 Recipe_AA NEED TO SHOW SUM OF FORMULA HERE
Group2 Batch ID_A THIS IS THE FORMULA diff(first-last timestamp)
Details section - suppressed
timestamp
timestamp
timestamp
timestamp
timestamp
Group2 Foooter - suppressed
Group2 Batch ID_B formula diff(first-last timestamp)
Details section - suppressed
timestamp
timestamp
timestamp
timestamp
timestamp
Group2 Foooter - supressed
Group1 Footer - suppressed

repeat many times.
The formula in my first post is in the header of group2.
It successfully shows us just the time between the first and last timestamp within that group.
It does not create a running total.

we now need to show in the header of group 1 the sum of the values displayed by the formula in all the group 2 headers within that group 1. It should not be a running total from one Group1 to another. Just the time for that Group.

hope that is clear
 
You cannot show the result in the recipe group header unless you insert a subreport that captures the results from a recipe group footer. If you are willing to do this, I will show you how.

-LB
 
Hi,
thanks for the reply, a sub-report is fine I think.
layout wise display in the header is desirable.
lets go with that.

The less desirable layout would be in the group footer.
I am curious how that would work too, as I could not get that to work either. If you have time for 2 explanations that would be great

thanks
mark
 
Save your current report as a subreport and then add the following formula {@accum} to your batchID group section (header or footer):

whileprintingrecords;
numbervar sumdiff := sumdiff + datediff("s",Minimum({Mixed_Material_Weighments.tstamp}, {Mixed_Material_BatchRef.Batch_ID}),
Maximum({Mixed_Material_Weighments.tstamp},{Mixed_Material_BatchRef.Batch_ID}));

In the recipe group footer, add this formula {@display}:
whileprintingrecords;
numbervar sumdiff;

In the recipe group header, add {@reset}:
whileprintingrecords;
numbervar sumdiff;
if not inrepeatedgroupheader then
sumdiff := 0;

Link the sub to the main report on the recipe field and place the subreport in the recipe group header. Suppress all sections within the subreport except the group footer section.

Alternatively, you could just create these formulas in the main report, with the result displayed in the recipe group footer.

-LB
 
You could summarize it in the same place you are calculating and display it in another formula:

@Seconds
whileprintingrecords;
global numbervar GT_Seconds;

dateTimeVar x:= Minimum
({Mixed_Material_Weighments.tstamp},{Mixed_Material_BatchRef.Batch_ID});
dateTimeVar y:= Maximum
({Mixed_Material_Weighments.tstamp},{Mixed_Material_BatchRef.Batch_ID});

numberVar totalSeconds:=DateDiff ("s",x ,y);
GT_Seconds := GT_Seconds + totalSeconds;
totalSeconds //putting this last makes it the return val

Display formula
@GTSeconds
global numbervar GT_Seconds;

This may require another formula once in a while to reset the value

@reset
global numbervar GT_Seconds := 0;

Scotto the Unwise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top