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

Reset counter problem

Status
Not open for further replies.

mcquam

Technical User
Feb 26, 2007
89
GB
I am not able to have my record count reset at the correct level. If I move the count, it divides by zero. At the moment it calculates ok at the group 1 level but I need it to reset at group 2 (months).

My report summarises the duration of legal services provided to clients. It is sorted into months and then client to show an average duration for each client and then for all clients for each month. I then deduct the 20% worst durations to give a net average duration). You provided the solution in an earlier thread (thread767-1338989) but you do not need to refer to it for this question. I am using CR9 and an access database.

The records are laid out like this:

completed cases ave days
Month1 32 22.47 (Group1)
Client1 549 30.49 (Group2)
Case1 SLAdays (Detail) - formula below
Case2 etc.

Group 1 header (counts the completion date field)
Group 2 footer (counts the completion date field and averages SLAdays)

Formulas:

@Accum (

whileprintingrecords;
numbervar cnt := cnt + 1;
numbervar cntx;
numbervar sumdiff;

if cnt > round(.2* Count ({FTRK_Reports.CompletionDate}, {FTRK_Reports.CompletionDate}, "monthly"))
then (cntx := cntx + 1;
sumdiff := sumdiff + {@SLAdays});


@Ave

whileprintingrecords;
numbervar cntx;
numbervar sumdiff;
sumdiff/cntx;

@Reset

whileprintingrecords;
numbervar cnt := 0;
numbervar cntx := 0;
numbervar sumdiff := 0;

@SLAdays

WhilereadingRecords;
//Set the values of Start Date and End Date
DateVar StartDate := Date({FTRK_Reports.MrtgOfferRcvd});
DateVar EndDate := Date({FTRK_Reports.CompletionDate});

//Find out the difference in days and subtract the weekends
NumberVar DaysDiff := (DateDiff("d",StartDate,EndDate)) -
DateDiff("ww",StartDate,EndDate,crsaturday) -
DateDiff("ww",StartDate,EndDate,crsunday);
 
In the Reset->Use a Formula on the Running Total try:

previous({table.group2field}) <> {table.group2field}

-k
 
Do you mean compare the 2 formulas - @SLAdays and @accum which are my running totals? SLAdays is sorted in descending order. If so I tried that and it gave me another "division by zero" error. I don't understand how cntx can be zero.
 
Are you trying to do averages at each group level? If so, you have to use separate variables for each calculation, since the resets will need to occur at different points. You also should specify where you are placing each formula (what report sections), if you need further help.

-LB
 
Thanks.

Yes. I want an average at group1 and group2 levels.

@reset - Group header 1
@accum - details
@SLAdays - details
@ave - Group footer 2

As you say, I am also looking for an average of the @SALdays and @ave.

-M
 
Your display formula should be in the same group as the reset formula, only in the footer section, so for what you have so far, {@ave} should be in GF1.

I can't really follow this, even looking at the previous thread, without seeing some sample data. Please show data and show the resulting averages and identify the report sections where they should appear.

-LB
 
OK I want to show the following:

Group 1 (months)
1. Count of cases by month
2. Average days taken to complete by month
3. Average of durations (eliminating the longest 20%) by month
Group 2 (client)
1. Count of cases by client by month
2. Average days taken to complete by client by month
3. Average of durations (eliminating the longest 20%) by client by month
Details (duration in days per case)
Case 1 32
Case 2 21
Case 3 40
Case 4 18
Case 5 12
Case 6 30
Case 7 11
Case 8 36


Here is some data from my report (sorry about the columns):

Completed cases Ave SLA (days) Standard case SLA
07/2006 43
Client1 43 14.14 8.12
08/2006 46
Client1 46 14.48 8.49
09/2006 79
Client1 79 14.64 10.97
10/2006 110
Client1 109 19.44 12.83
Client2 1 8.00 12.77
11/2006 157
Client1 88 23.05 12.56
Client3 37 11.86 12.16
Client2 32 14.22 12.68
12/2006 170
Client1 104 21.16 12.30
Client3 31 15.00 13.13
Client2 35 16.20 13.92
01/2007 253
Client1 131 25.26 15.80
Client3 70 21.10 18.13
Client2 52 24.71 19.83
02/2007 235
Client1 122 22.81 8.51
Client3 66 13.58 10.79
Client2 47 21.42 13.22
03/2007 82
Client1 48 24.66 8.88
Client3 25 18.39 12.40
Client2 9 16.33 12.94

Ave SLA is the average duration and Standard is duration less worst 20%.

Layout currently:
GH1 - count of cases
GH2 - empty
Details - @SLAdays and @accum
GF2 - evarage of @SLAdays and @ave
GF1 - blank
 
Sorry, but I can't see what you're doing because you're not showing the detail level fields that contribute to the averages.

-LB
 
In the 3 columns showing numbers above:
Column1 is: countofFTRK_Reports.CompletionDate(Number)
Column2(detail) is: @SLAdays the formula for which is shown above
Column3 (detail) is: @accum also shown above
The other fields in the detail section are:
({FTRK_Reports.MrtgOfferRcvd}); and
({FTRK_Reports.CompletionDate});
which are the start and end dates for the durations.
 
I meant for you to show sample data at the detail level that shows the fields used in the calculations and then show the what the averages would be that you want to calculate. I also don't have a clue what standard case SLA is or why that's relevant.

-LB
 
Here is some data:

12/2006 170
27-Jul-2006 24-Dec-2006 106 0
12-Sep-2006 29-Dec-2006 78 0
20-Sep-2006 29-Dec-2006 72 0
20-Sep-2006 17-Dec-2006 62 0
06-Sep-2006 01-Dec-2006 62 0
13-Sep-2006 06-Dec-2006 60 0
13-Sep-2006 01-Dec-2006 57 0
11-Oct-2006 22-Dec-2006 52 0
11-Oct-2006 24-Dec-2006 52 0
19-Oct-2006 21-Dec-2006 45 0
04-Oct-2006 02-Dec-2006 42 0
19-Oct-2006 16-Dec-2006 41 0
30-Oct-2006 23-Dec-2006 39 0
13-Nov-2006 30-Dec-2006 34 0
13-Nov-2006 29-Dec-2006 34 0
24-Oct-2006 08-Dec-2006 33 0
18-Oct-2006 01-Dec-2006 32 0
08-Nov-2006 22-Dec-2006 32 0
23-Oct-2006 01-Dec-2006 29 0
13-Nov-2006 23-Dec-2006 29 0
10-Nov-2006 21-Dec-2006 29 0
13-Nov-2006 22-Dec-2006 29 0
07-Nov-2006 16-Dec-2006 28 0
10-Nov-2006 20-Dec-2006 28 0
21-Nov-2006 29-Dec-2006 28 0
25-Oct-2006 01-Dec-2006 27 0
11-Nov-2006 17-Dec-2006 25 0
03-Nov-2006 07-Dec-2006 24 0
31-Oct-2006 01-Dec-2006 23 0
01-Nov-2006 01-Dec-2006 22 0
20-Nov-2006 20-Dec-2006 22 0
29-Nov-2006 29-Dec-2006 22 0
02-Nov-2006 01-Dec-2006 21 0
16-Nov-2006 15-Dec-2006 21 0
30-Nov-2006 29-Dec-2006 21 21
23-Nov-2006 22-Dec-2006 21 42
25-Nov-2006 22-Dec-2006 20 62
03-Nov-2006 01-Dec-2006 20 82
03-Nov-2006 02-Dec-2006 20 102
24-Nov-2006 22-Dec-2006 20 122
25-Nov-2006 24-Dec-2006 20 142
06-Nov-2006 02-Dec-2006 19 161
10-Nov-2006 07-Dec-2006 19 180
13-Nov-2006 09-Dec-2006 19 199
20-Nov-2006 16-Dec-2006 19 218
13-Nov-2006 07-Dec-2006 18 236
08-Nov-2006 01-Dec-2006 17 253
15-Nov-2006 08-Dec-2006 17 270
29-Nov-2006 24-Dec-2006 17 287
06-Dec-2006 31-Dec-2006 17 304
30-Nov-2006 23-Dec-2006 16 320
30-Nov-2006 24-Dec-2006 16 336
30-Nov-2006 21-Dec-2006 15 351
29-Nov-2006 20-Dec-2006 15 366
10-Nov-2006 01-Dec-2006 15 381
25-Nov-2006 16-Dec-2006 15 396
23-Nov-2006 14-Dec-2006 15 411
23-Nov-2006 14-Dec-2006 15 426
30-Nov-2006 20-Dec-2006 14 440
17-Nov-2006 07-Dec-2006 14 454
25-Nov-2006 14-Dec-2006 14 468
01-Dec-2006 21-Dec-2006 14 482
04-Dec-2006 22-Dec-2006 14 496
22-Nov-2006 08-Dec-2006 12 508
15-Nov-2006 01-Dec-2006 12 520
06-Dec-2006 23-Dec-2006 12 532
20-Nov-2006 06-Dec-2006 12 544
29-Nov-2006 16-Dec-2006 12 556
13-Dec-2006 29-Dec-2006 12 568
23-Nov-2006 08-Dec-2006 11 579
06-Dec-2006 21-Dec-2006 11 590
22-Nov-2006 07-Dec-2006 11 601
28-Nov-2006 13-Dec-2006 11 612
30-Nov-2006 16-Dec-2006 11 623
28-Nov-2006 13-Dec-2006 11 634
30-Nov-2006 15-Dec-2006 11 645
30-Nov-2006 17-Dec-2006 11 656
30-Nov-2006 14-Dec-2006 10 666
25-Nov-2006 09-Dec-2006 10 676
06-Dec-2006 20-Dec-2006 10 686
20-Nov-2006 01-Dec-2006 9 695
25-Nov-2006 07-Dec-2006 9 704
27-Nov-2006 09-Dec-2006 9 713
04-Dec-2006 15-Dec-2006 9 722
04-Dec-2006 16-Dec-2006 9 731
04-Dec-2006 17-Dec-2006 9 740
27-Nov-2006 09-Dec-2006 9 749
21-Nov-2006 02-Dec-2006 8 757
28-Nov-2006 08-Dec-2006 8 765
12-Dec-2006 24-Dec-2006 8 773
12-Dec-2006 22-Dec-2006 8 781
12-Dec-2006 22-Dec-2006 8 789
19-Dec-2006 29-Dec-2006 8 797
22-Nov-2006 01-Dec-2006 7 804
06-Dec-2006 15-Dec-2006 7 811
13-Dec-2006 22-Dec-2006 7 818
12-Dec-2006 21-Dec-2006 7 825
23-Nov-2006 01-Dec-2006 6 831
30-Nov-2006 09-Dec-2006 6 837
30-Nov-2006 10-Dec-2006 6 843
25-Nov-2006 02-Dec-2006 5 848
08-Dec-2006 16-Dec-2006 5 853
04-Dec-2006 10-Dec-2006 4 857
18-Dec-2006 22-Dec-2006 4 861
Client1 104 21.16 12.30
16-Nov-2006 31-Dec-2006 31 892
01-Nov-2006 13-Dec-2006 30 922
07-Nov-2006 13-Dec-2006 26 948
21-Nov-2006 22-Dec-2006 23 971
28-Nov-2006 30-Dec-2006 23 994
02-Nov-2006 03-Dec-2006 21 1015
08-Nov-2006 07-Dec-2006 21 1036
23-Nov-2006 21-Dec-2006 20 1056
22-Nov-2006 20-Dec-2006 20 1076
27-Nov-2006 20-Dec-2006 17 1093
21-Nov-2006 14-Dec-2006 17 1110
17-Nov-2006 10-Dec-2006 15 1125
23-Nov-2006 14-Dec-2006 15 1140
11-Nov-2006 02-Dec-2006 15 1155
30-Nov-2006 20-Dec-2006 14 1169
21-Nov-2006 08-Dec-2006 13 1182
28-Nov-2006 16-Dec-2006 13 1195
05-Dec-2006 23-Dec-2006 13 1208
13-Dec-2006 29-Dec-2006 12 1220
16-Nov-2006 02-Dec-2006 11 1231
30-Nov-2006 16-Dec-2006 11 1242
07-Dec-2006 21-Dec-2006 10 1252
01-Dec-2006 16-Dec-2006 10 1262
24-Nov-2006 10-Dec-2006 10 1272
06-Dec-2006 20-Dec-2006 10 1282
20-Nov-2006 01-Dec-2006 9 1291
20-Nov-2006 03-Dec-2006 9 1300
27-Nov-2006 07-Dec-2006 8 1308
13-Dec-2006 22-Dec-2006 7 1315
23-Nov-2006 01-Dec-2006 6 1321
14-Dec-2006 21-Dec-2006 5 1326
Client2 31 15.00 13.13
09-Nov-2006 30-Dec-2006 36 1362
28-Oct-2006 08-Dec-2006 30 1392
03-Nov-2006 09-Dec-2006 25 1417
10-Nov-2006 14-Dec-2006 24 1441
20-Nov-2006 21-Dec-2006 23 1464
07-Nov-2006 09-Dec-2006 23 1487
20-Nov-2006 21-Dec-2006 23 1510
16-Nov-2006 17-Dec-2006 21 1531
01-Dec-2006 29-Dec-2006 20 1551
13-Nov-2006 08-Dec-2006 19 1570
04-Dec-2006 29-Dec-2006 19 1589
05-Dec-2006 29-Dec-2006 18 1607
27-Nov-2006 21-Dec-2006 18 1625
05-Dec-2006 29-Dec-2006 18 1643
29-Nov-2006 22-Dec-2006 17 1660
22-Nov-2006 17-Dec-2006 17 1677
30-Nov-2006 24-Dec-2006 16 1693
22-Nov-2006 14-Dec-2006 16 1709
07-Dec-2006 29-Dec-2006 16 1725
30-Nov-2006 23-Dec-2006 16 1741
10-Nov-2006 01-Dec-2006 15 1756
30-Nov-2006 21-Dec-2006 15 1771
28-Nov-2006 17-Dec-2006 13 1784
25-Nov-2006 13-Dec-2006 13 1797
04-Dec-2006 21-Dec-2006 13 1810
29-Nov-2006 15-Dec-2006 12 1822
30-Nov-2006 16-Dec-2006 11 1833
24-Nov-2006 09-Dec-2006 10 1843
01-Dec-2006 17-Dec-2006 10 1853
01-Dec-2006 16-Dec-2006 10 1863
07-Dec-2006 21-Dec-2006 10 1873
19-Dec-2006 29-Dec-2006 8 1881
05-Dec-2006 14-Dec-2006 7 1888
15-Dec-2006 20-Dec-2006 3 1891
29-Nov-2006 01-Dec-2006 2 1893
Client3 35 16.20 13.92

As you will see, I'm calculating the business days between two dates and then calculating an average. The second stage (the Standard case SLA I refer to) aims to calculate a new average for the business days but excluding the worst 20% of cases.
 
The formula only excludes the worst 20% on the first client, which isn't necessarily the worst 20% per month, which it appears you are trying to do. Any other calculations will be incorrect because of that.

-LB
 
I'm afraid I don't understand how to do that. Perhaps you can explain.
 
Whe I move the @reset into the other group I get a division by zero error. Can anyone help?
 
I am actually trying to get the worst 20% for each client per month.
 
I have tried this every way I can think of but am no further forward. I'd be grateful for a little more guidance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top