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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula In Header That Totals Supressed Detail Data

Status
Not open for further replies.

MomentSurfer

IS-IT--Management
Mar 7, 2006
13
CA
My report shows a series of amounts in the details section of a group. Some of the amounts are conditionally supressed (e.g. when date < #some date#). I need to show the total of the supressed amounts in the group's header. How should this be approached?

I created a formula and inserted it into the detail section. The formula applies the same logic as the supression so that it can keep a running total of the supressed amounts. The sum is accurate, however the value is only available when the formula is placed in the group footer. I need it in the header. I have tried using EvaluateAfter() in my formula and basing it on a field that appears in the footer but this seems to have no effect.

Any help you can provide would be greatly appreciated.

Thanks for your time.

David
 
Running Totals are executed at the WhilePrintingRecords phase and this has the effect of not allowing you to show them in the header sections (as they are probably being reset to zero at that point)

You need another approach which is to create a formula which says:

Code:
if <your_condition> then <your_value_field> else 0

Insert a normal summary on this formula field.



Steve Phillips, Crystal Trainer/Consultant
 
I assume you are using running totals to get a conditional total, excluding some dates. This, unfortunately, will be calculated as the report prints and so can only be shown in the footer.

What you could do is add an extra group, say
Code:
 If date < #some date then "A" else "B"
You could then do summary totals for Group A and put them in the higher group header. Suppress the group header and footer of the new group.

Right-click on a field and choose Insert to get a choice of Running Total or Summary. Or else use the Field Explorer, the icon that is a grid-like box, to add running totals.

Running totals allow you to do clever things with grouping and formulas. They also accumulate for each line, hence the name. The disadvantage is that they are working out at the same time as the Crystal report formats the line. You cannot test for their values until after the details have been printed. You can show them in the group footer but not the group header, where they will be zero if you are resetting them for each group.

Summary totals are cruder, but are based directly on the data. This means that they can be shown in the header. They can also be used to sort groups, or to suppress them. Suppress a group if it has less than three members, say. They default to 'Grand Total', but also can be for a group.


[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Thank you for your quick responses!

I am using the 3 step approach using parameters (as opposed to running totals): 1) initialization in the group header, 2) calculation in the details, and 3) display in the header. Each step has its own parameter and they all refer to the same variable name.

The calculation formula applies the same logic that is used in the compression formula and only adds the new detail amount if it is not supressed.

This approach is working well, except the data is not available in the group header for my "display" formula. If I temporarily move the "display" formula to the footer it works fine.

David

 
You'll need to adopt the formula method I mentioned earlier. Unless, of course, the formula you use needs to be a WhilePrintingRecords formula!

With my suggestion, the formula is evaluated whilst reading the data from the database and is therefore available for normal subtotalling (which can be shown in the header)

Steve Phillips, Crystal Trainer/Consultant
 
Thank you, once again, for the help you both provided. I like all of the suggestions.

I implemented the additional group approach (splitting on date) and used some additional group supression formulas to get the display I needed.

Everything is now working thanks to your help!

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top