average of 5

M

mrbob16

I have a spreadsheet in cell b13 I start entering data till b59. I want to
take a running average of the last 5 cells that contain data. Not all cells
will have an entry and every 6th cell has a different formula. I also want to
move this running average to row c.
 
M

Max

One way to model it up for delivery

Target range is B13:B59
In C13: =IF(COUNT(B13)=0,"",ROWS($1:1))
In D13: =INDEX($B$13:$B$59,SMALL($C$13:$C$59,ROWS($1:1)))
Copy C13:D13 down to D59. This dynamically screens the target range in col B
for numbers, and then packs it up in col D (makes it into a contiguous range)

Then place in say, E13:
=IF(COUNT($D$13:$D$59)<5,"",
AVERAGE(OFFSET($D$13,COUNT($D$13:$D$59)-1,,-5)))

E13 will return the desired running average of the last 5 cells
that contain data within the target range
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:20,500 Files:363 Subscribers:64
xdemechanik
 
M

mrbob16

I am using a lot of columns and those cells are being used. If I get what you
are saying is I have to make a small database that will then average the
numbers in order they are placed there? And would it be easier if I sent you
what I'm working on so you can see it or just try to put it in here.

thanks
bob
 
S

Shane Devenshire

Hi,

When you say every 6th cell has a different formula, what are you telling
us? Should we be ignoring every 6th cell? Why don't you show us some sample
data. We are supposed to average the last 5 cells with entries but ?? what
about that 6th cell. So are you saying your data might look like this:

Bob
5
11/1/2008
4
Red

34

Green
Blue
13
23

54

so a running average beside the last cell would average from Green to 54?
That's five cells with entries. Or should it average from 4 to 54? But if
the number 13 is one of those "other formulas" we should average from 5 to
54? And if the cell above 54 contains a spacebar, then what? Do we average
through the date or ignore it or what?

Thanks,
Shane Devenshire
 
M

mrbob16

I'll try to do it here

col a col b col c
11-1-08 2.547
11/2/08 2.555 need avg
11/3/08 2.560 need avg of 3
11/4/08 2.575 need avg of 4
11/4/08 need avg of 4or 5 if there is data
blank avg of the avgs
11/5/08 2.575 avg of last 5
11/5/08 blank avg of last 5
11/6/08 2.580 avg of last 5

all columns to the right of c contain other data and the avg line is
basically an avg of those 5 rows above whether they have data or not but I
need to keep a running avg in col c for just the last five cells in colb that
have data not blanks. I hopw this helps.

I'm not to great with computers so max I'll try and get it uploaded. I hope
this will help.

thanks
bob
 
M

mrbob16

My file is way to big for the minimum. But I posted an example and maybe that
would help.
 
M

mrbob16

Well I must thank you anyway because I and my coworkers have been working on
this for about 2 months now and we thought it has to be simpler than having
to to do it manuallyeach time and without setting up a data base to grab it
from. So again I thank you for your time and if you do find a way let me know

thanks
 
M

mrbob16

http://freefilehosting.net/download/42g42
hey Max I tried again to upload that problem and realized it said 5mb and i
thought it said 5kb so i didn't think it would fit but here it is and i tried
to explain what i need on the bottom of the page.

thanks again if could look at it one more time.
 
M

Max

I'm afraid it's the same conclusion, Bob.

There are 2 issues with your requirements which seem insurmountable to me
a. That you want an average result on every line in col C, but it is to
somehow disregard any interceding blanks in col B as part and parcel of the
"last 5" data rows
b. The "interceding" difficulty is further compounded by the presence of a
6th "average" line after each set of 5 lines reserved for data in col B which
contains a different formula in col C, and this 6th line is to be, like the
blanks in col B, somehow skipped in the desired average of the last 5 cells
with data in col B

FWIW, here's my best scenario should you decide to review your specs /
layout re-design. Supposing the data is continuous in B13 down (w/o any
interceding blank cells nor breaks every 6th line), and you want an average
of the last 5 cells with data in col B to reflect in col C, then in C13,
copied down:
=AVERAGE(OFFSET(B13,,,-MIN(COUNT(B$13:B13),5)))
will return those results. The top 4 formula cells, ie C13:C16 will return
the desired average of last 1 to 4 data cells in col B, while C17, C18, etc
down will return the "last 5".
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:20,500 Files:365 Subscribers:65
xdemechanik
 
M

mrbob16

Thanks again for looking at my problem. Would it be alright if I redesign it
and send you the new format and see if what you wrote would work before I go
changing everything. Believe it or not I need this for one little spec out of
I can't tell you how many that are more important but I still need it.

thanks again
bob
 
M

Max

Suggest you start a new thread for your revised specs/set-up
Avail your post to all responders
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:20,500 Files:365 Subscribers:65
xdemechanik
---
mrbob16 said:
Thanks again for looking at my problem. Would it be alright if I redesign
it
and send you the new format and see if what you wrote would work before I
go
changing everything. Believe it or not I need this for one little spec out
of
I can't tell you how many that are more important but I still need it.

thanks again
bob
..
 
S

Spiky

Thanks again for looking at my problem. Would it be alright if I redesignit
and send you the new format and see if what you wrote would work before Igo
changing everything. Believe it or not I need this for one little spec out of
I can't tell you how many that are more important but I still need it.

Well, I couldn't make what Max wrote earlier work, but the concept of
a helper column is valid, if you ask me. No matter how many columns
you have, you can add another. Unless you are actually at the maximum
width. It doesn't have to be column D, it can be far away if
necessary. So, if using row 13 as the starting point as in previous
examples, and column EA as your helper column....

In column EA:
EA13 =1
EA14 =IF(COUNT(B14)=0,EA13,EA13+1)

In column C:
C13 =AVERAGE(INDIRECT("B"&12+
IF(ISNA(MATCH(EA13-4,$EA$13:EA13,0)),
1,MATCH(EA13-4,$EA$13:EA13,0))):B13)

(I broke that formula up for display here, put it back together in
Excel with no spaces)
 
S

Spiky

You know, I forgot about wanting a different average every 6th cell.
But I don't understand that part. If your 5-cell average may cover
more than 5 contiguous rows due to blanks, what does an average of the
averages mean every 6th row? It would vary, if you ask me. Should it
be an average of the last 5 unique averages, instead?

Also, how do you make space for this in a column of different average
formulas? See, if you come to row 24, which should be a "6th row
average" with a different formula, and if there are amounts in B24 and
B25 rather than blanks, then your average of 5 cells where B24 is the
5th cell will NEVER show up. So you've just lost a data point.

I guess my point is that the "6th row average" ought to be 2 different
things than you have outlined. From what I see, anyway.

1) Perhaps, it should be an average of the last 5 unique averages, not
the last 5 rows.
2) But definitely, it ought to be in a separate column so as not to
lose data in Column C.
 
M

mrbob16

If I could spiky can I send you the chart. it is a little easier to show than
to explain.
The different formula for the sixth cell is in column c for the averages of
the the last five tests whether there is number or not and it is just for
that column. What I need is a running average in the other cells to get that
average. again let me know if I could send it to you or upload it to you so
you can visualize what I mean.

Thanks
bob
 
M

mrbob16

Actually Spiky the file is still available if you look at the reply I left on
12/2 to max the link is still there to download.
 
S

Spiky

I tried my solution in your file and it works, just plug it into the
particular cells like I said above and then copy C13 to each cell
where it belongs, and copy EA14 down as far as necessary (at least to
EA59). And it will ignore the fact that the 6th row is different as
long as you don't put anything in B18, B24, etc.

I'm still not exactly sure what you want in the 6th cell, like C18,
C24, etc. In different posts you've indicated 2 or 3 different ideas
for these cells, and another in the file itself. I think one of these
is all you are looking for, and it can be copied to each cell where
you want it:
C18: =AVERAGE(C13:C17)
*or*
C18: =AVERAGE(B13:B17)

BTW:
After using a column off to the right like this, change your print
settings to NOT include it. Otherwise you'll get lots of extra paper.

And you don't have to use column EA, it could be any empty column.
You'd just have to change each instance of "EA" to whatever column you
use in each formula.
 
B

Bernd P

Hello,

I suggest to go this route:

Example:

Values in A13:D27:
1 1 13 1
1 2 14 1.5
1 3 15 2
1 15 2
15 2
2 4 16 2.5
2 5 17 3
2 6 18 4
2 7 19 5
19 4
3 19 5
3 8 20 6
3 9 21 7
3 10 22 8
22 5.5

Formulas in A13:D27:
1 1 =ROW() =IF(ISBLANK(A13),AVERAGE(B$13:B13),AVERAGE(INDEX($B$13:$B
$26,IFERROR(MATCH(C13-4,$C$13:$C$26,0),1)):B13))
1 2 =C13+1-ISBLANK(B14) =IF(ISBLANK(A14),AVERAGE(B$13:B14),AVERAGE
(INDEX($B$13:$B$26,IFERROR(MATCH(C14-4,$C$13:$C$26,0),1)):B14))
1 3 =C14+1-ISBLANK(B15) =IF(ISBLANK(A15),AVERAGE(B$13:B15),AVERAGE
(INDEX($B$13:$B$26,IFERROR(MATCH(C15-4,$C$13:$C$26,0),1)):B15))
1 =C15+1-ISBLANK(B16) =IF(ISBLANK(A16),AVERAGE(B$13:B16),AVERAGE(INDEX
($B$13:$B$26,IFERROR(MATCH(C16-4,$C$13:$C$26,0),1)):B16))
=C16+1-ISBLANK(B17) =IF(ISBLANK(A17),AVERAGE(B$13:B17),AVERAGE(INDEX
($B$13:$B$26,IFERROR(MATCH(C17-4,$C$13:$C$26,0),1)):B17))
2 4 =C17+1-ISBLANK(B18) =IF(ISBLANK(A18),AVERAGE(B$13:B18),AVERAGE
(INDEX($B$13:$B$26,IFERROR(MATCH(C18-4,$C$13:$C$26,0),1)):B18))
2 5 =C18+1-ISBLANK(B19) =IF(ISBLANK(A19),AVERAGE(B$13:B19),AVERAGE
(INDEX($B$13:$B$26,IFERROR(MATCH(C19-4,$C$13:$C$26,0),1)):B19))
2 6 =C19+1-ISBLANK(B20) =IF(ISBLANK(A20),AVERAGE(B$13:B20),AVERAGE
(INDEX($B$13:$B$26,IFERROR(MATCH(C20-4,$C$13:$C$26,0),1)):B20))
2 7 =C20+1-ISBLANK(B21) =IF(ISBLANK(A21),AVERAGE(B$13:B21),AVERAGE
(INDEX($B$13:$B$26,IFERROR(MATCH(C21-4,$C$13:$C$26,0),1)):B21))
=C21+1-ISBLANK(B22) =IF(ISBLANK(A22),AVERAGE(B$13:B22),AVERAGE(INDEX
($B$13:$B$26,IFERROR(MATCH(C22-4,$C$13:$C$26,0),1)):B22))
3 =C22+1-ISBLANK(B23) =IF(ISBLANK(A23),AVERAGE(B$13:B23),AVERAGE(INDEX
($B$13:$B$26,IFERROR(MATCH(C23-4,$C$13:$C$26,0),1)):B23))
3 8 =C23+1-ISBLANK(B24) =IF(ISBLANK(A24),AVERAGE(B$13:B24),AVERAGE
(INDEX($B$13:$B$26,IFERROR(MATCH(C24-4,$C$13:$C$26,0),1)):B24))
3 9 =C24+1-ISBLANK(B25) =IF(ISBLANK(A25),AVERAGE(B$13:B25),AVERAGE
(INDEX($B$13:$B$26,IFERROR(MATCH(C25-4,$C$13:$C$26,0),1)):B25))
3 10 =C25+1-ISBLANK(B26) =IF(ISBLANK(A26),AVERAGE(B$13:B26),AVERAGE
(INDEX($B$13:$B$26,IFERROR(MATCH(C26-4,$C$13:$C$26,0),1)):B26))
=C26+1-ISBLANK(B27) =IF(ISBLANK(A27),AVERAGE(B$13:B27),AVERAGE(INDEX
($B$13:$B$26,IFERROR(MATCH(C27-4,$C$13:$C$26,0),1)):B27))

Please note that I did not apply an average of averages but just a
simple total average which I regard as correct (better).

IFERROR(exp1,expr2) is an Excel 2007 function. In older versions you
would have to write IF(ISERROR(expr1),expr2,expr1).

Regards,
Bernd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top