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

How to Reset Rolling Numbers?

Status
Not open for further replies.

semoryrig

Technical User
Jan 25, 2010
3
US
Hi,

I'm creating a report that pulls rolling numbers for each day during a given time frame and it's pulling this information for separate users and needs to be displayed per user.

Example:

User1 Calls/day "Should be" total Rolling Total (currently showing)
10/1/10 0 0 0
10/4/10 24 24 24
10/5/10 23 47 47
10/6/10 30 77 77
10/7/10 23 100 100
10/8/10 17 117 117
10/15/10 1 118 118
User2 (should reset here)
12/10/10 1 1 119
12/13/10 0 1 95
12/14/10 0 1 72


I need to figure out how to reset the Rolling Totals every time it hits a new username.

I'm using the following formula to generate the rolling numbers; it can also be found in this post
numbervar the_field := {@ActivityPoints};
numbervar array Accum;
numbervar Rolling_Period := 7;

if OnFirstRecord then
ReDim Accum [1]
else
ReDim Preserve Accum [UBound(Accum)+1];

Accum [UBound(Accum)] := the_field;

If UBound(Accum) <= Rolling_Period then
Sum(Accum)
Else
sum(Accum[(UBound(Accum) - (Rolling_Period-1)) to UBound(Accum)]);


I'm using Crystal Reports version 11.5.0.313.

Any help would be greatly appreciated!
 
What you are showing here is not a rolling sum, but instead a running total. You should be able to simply insert a running total that does a sum of calls/day and resets on change of group (user).

A rolling total would be one, e.g., where it was reset so that for each row, the sum was for the last n number of records.

-LB
 
Thanks for the response. I should have been clearer or included more data. I am using a running total for the last 7 days.

User 1 Calls
1 1
2 3
3 6
4 10
5 15
6 21
7 28
2 29
1 28
1 26


That part is working fine and my totals are coming out correctly, but I can't get the rolling 7 days to "start over" at each new user.
 
Add a reset formula in the user group header:

whileprintingrecords;
numbervar array Accum;
if notinrepeatedgroupheader then
accum := "";
"" //Add this so the formula will be accepted.

-LB
 
I tried using that reset formula, but it won't accept it and keeps telling me a number array is required at "".

Thanks again for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top