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

Sum of a Sum

Status
Not open for further replies.
Jun 23, 2008
55
GB
I have a report that is grouped on Client, then in the details for each client there are various numbers of History records. In the history records I have the following formula:

If {CR_HISTORY.HistoryType_Ref} = 'G' and {CR_HISTORY.DateStart} < {BDPTransitionReviews.DateStart} then 1 else 0
(This is called @SeenPrior)

Each Client may have more than one history where this formula is true and I need to count the Clients (who have at least one true) rather than the individual histories.

So in the group on Clients I have put the following formula:

If Sum ({@SeenPrior}, {CR_CLIENTS.Client_Ref})>=1 then 1 else 0 This is called @SeenPriorY/N)

I now need to work out the total of the above but I can't do a sum of a sum. Is there anyway around this?

Someone has mentioned While Printing Records to me but I've no idea how or where to use this and the help files don't explain much.

Regards
Annie
 
Use a variable change your formula

@SeenPriorY/N
whileprintingrecords;

global numbervar seenprior;

If Sum ({@SeenPrior}, {CR_CLIENTS.Client_Ref})>=1 then
seenprior:= seenprior+1

In report footer
@display
whileprintingrecords;

global numbervar seenprior;

Ian
 
Thanks Ian, just one more thing (I probably should've mentioned prior), my clients are contained with another group and I need to reset the accumulator for each group. Is this possible?
 
Use a reset formula placed in the outer group header:

whileprintingrecords;
numbervar seenprior;
if not inrepeatedgroupheader then
seenprior := 0;

Global variables are the default, so "global" does not have to be specified.

Please note that you are in the wrong forum. For questions like this, please post in forum767 or forum149.

-LB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top