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!

Count formula

Status
Not open for further replies.

LHG33

Technical User
Jan 16, 2002
24
US
I need a formula that will count a field (Amount) and reset when it reaches the number in a field (Page Count), or if it does not exceed the Page Count it will show it's count. The report is grouped and I must do this within those groups. Example:

(The Page Count is equal to 155)

GROUP 1
Amount Items
$5034.00 155
$7656.65 155
$5645.34 85


This example counted to 155 twice and displayed the remainder for the last record in the group. Please help!
 
I need a better understanding of what you're trying to do.

I'm guessing that you don't mean that {page count} is a field, rather it is counting formula, and you'd like to reset it when it reaches 150.

But I'll await clarification.

-k kai@informeddatadecisions.com
 
Where do these numbers print? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
To answer synapsevampire's question, the Page Count is a number field that is usually set by a client in their database. I need to count the Amounts until they reach whatever is in the Page Count field (the example was 155) and then have the count reset and continue counting. If what is left is less than the Page Count field, it will just print the remainder.

Mr. Hamady, I am printing all my info in the body of the report using the Details section.

If you need any more info, please let me know.
 
I am puzzled, because you have 400+ amounts but you are only showing 3 lines. What should the output look like? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
You want a counter of the rows in the detail section, which will reset to 0 when it is equal to the {page count} field, then store the total {page count} correct?

It sounds like you understand variables, so I'll just pass theory, if not, let me know:

group header level formula to reset a counter variable (numbervar) and a totalpagecountmet variable (booleanvar) set to false

detail level brings in these variables and checks for the counter = {page count} and totalpagecountmet = false, if yes, counter is set to 0 and totalpagecountmet is set to true, else, counter = counter + 1

This will continue adding to the counter unless it's reset time, or continually after reset time because the totalpagecountmet variable is set to true.

group footer variable brings in totalpagecountmet, which if true, displays {page count}-counter (this may result in a negative number if you have more addiional records than {page count} is set to.

Should get you there.

-k kai@informeddatadecisions.com
 
Thank you both for your responses! The output will look like the example above--even if there are pages of amounts. I appreciate your theory, SV, and it sounds exactly like what I need to do. However, I have very little knowledge of code so I need to look up how to say what I want. By the way, if you guys know of a good book I can buy that will educate me in crystal syntax, please let me know.

Again, thank you both!
 
Hooray! I have some formulas in there and I have the numbers counting the amounts and resetting at the value in the Page Count field! Unfortunately, I still need to figure out the code to make the remainder appear and then a code used in Details under Suppression to make only the count = Page Count and the last remainder for the group to show along with All of the amounts.

Ex:

$456 155
$345 155
$332 155
$234 155
$35 20

So, in other words, the count = Page Count would show beside every amount until there is a remainder.
 
Again, you lost me with what's missing, I was taking a wild stab at the original requirement...

The remainder meaning the counter - {page count}? If so, use a formula in the group footer:

whileprintingrecords;
numbervar counter;
booleanvar totalpagecountmet;

If totalpagecountmet = true then
counter

This would show the number of rows AFTER the reset, is that not what you want?

The detail suppression would be

whileprintingrecords;
booleanvar totalpagecountmet;

totalpagecountmet

This will suppress rows beyond the {page count}

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top