Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Formula to average the last 4 non-blank numerical cells of a row?

I am tracking weekly scores in a table and want to be able to calculate a
4-entry trailing average. Not every cell will have a value, so the last 4
entries might be spread over more than 4 cells in the row. For example,
tracking player point totals over a period of weeks, a player might be sick
one week and thus not have points that week, so the cell would be blank (as
opposed to zero).
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Formula to average the last 4 non-blank numerical cells of a row?

The below are all ARRAY FORMULAS:

For sporadic values in A1:J1

K1:
=SUMPRODUCT(ISNUMBER(MATCH(COLUMN(A1:J1),LARGE(((A 1:J1<0)*COLUMN(A1:J1))+((A1:J1=0)*0),{1,2,3,4}),0 ))*A1:J1)/5

Or, if there may be less than 4 items and the available items are to be
averaged
K1:
=SUMPRODUCT(ISNUMBER(MATCH(COLUMN(A1:J1),LARGE(((A 1:J1<0)*COLUMN(A1:J1))+((A1:J1=0)*0),{1,2,3,4}),0 ))*A1:J1)/MIN(4,SUMPRODUCT(--(A1:J1<0)))

or

=AVERAGE(J1:INDEX(A1:J1,LARGE(IF(A1:J1<"",COLUMN( A1:J1)),MIN(COUNT(A1:J1),4))))

Note: For array formulas, hold down [Ctrl] and [Shift] when you press
[Enter], instead of just pressing [Enter].

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"VB Coach" wrote:

I am tracking weekly scores in a table and want to be able to calculate a
4-entry trailing average. Not every cell will have a value, so the last 4
entries might be spread over more than 4 cells in the row. For example,
tracking player point totals over a period of weeks, a player might be sick
one week and thus not have points that week, so the cell would be blank (as
opposed to zero).

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Formula to average the last 4 non-blank numerical cells of a r

Typo! (sorry)

The first formula should end with 4....not 5:
=SUMPRODUCT(ISNUMBER(MATCH(COLUMN(A1:J1),LARGE(((A 1:J1<0)*COLUMN(A1:J1))+((A1:J1=0)*0),{1,2,3,4}),0 ))*A1:J1)/4

***********
Regards,
Ron

XL2002, WinXP


"Ron Coderre" wrote:

The below are all ARRAY FORMULAS:

For sporadic values in A1:J1

K1:
=SUMPRODUCT(ISNUMBER(MATCH(COLUMN(A1:J1),LARGE(((A 1:J1<0)*COLUMN(A1:J1))+((A1:J1=0)*0),{1,2,3,4}),0 ))*A1:J1)/5

Or, if there may be less than 4 items and the available items are to be
averaged
K1:
=SUMPRODUCT(ISNUMBER(MATCH(COLUMN(A1:J1),LARGE(((A 1:J1<0)*COLUMN(A1:J1))+((A1:J1=0)*0),{1,2,3,4}),0 ))*A1:J1)/MIN(4,SUMPRODUCT(--(A1:J1<0)))

or

=AVERAGE(J1:INDEX(A1:J1,LARGE(IF(A1:J1<"",COLUMN( A1:J1)),MIN(COUNT(A1:J1),4))))

Note: For array formulas, hold down [Ctrl] and [Shift] when you press
[Enter], instead of just pressing [Enter].

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"VB Coach" wrote:

I am tracking weekly scores in a table and want to be able to calculate a
4-entry trailing average. Not every cell will have a value, so the last 4
entries might be spread over more than 4 cells in the row. For example,
tracking player point totals over a period of weeks, a player might be sick
one week and thus not have points that week, so the cell would be blank (as
opposed to zero).

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Formula to average the last 4 non-blank numerical cells of a row?

Try one of these. Both formulas are array formulas and need to be entered
using the key combination of CTRL,SHIFT,ENTER (not just ENTER):

This one will average the last 4 entries in row 1 (A1:IV1). If there are not
at least 4 entries to average the formula returns an error:

=AVERAGE(IF(COLUMN(1:1)=LARGE(IF(1:1,COLUMN(1:1)) ,4),IF(1:1,1:1)))

This version will average the last 4 entries in row 1 (A1:IV1). If there are
not at least 4 entries to average the formula will average the last n
entries up to 4. If there are *no* numbers to average the formula returns an
error.

=AVERAGE(IF(COLUMN(1:1)=LARGE(IF(1:1,COLUMN(1:1)) ,MIN(COUNTIF(1:1,"0"),4)),IF(1:1,1:1)))

Biff

"VB Coach" <VB wrote in message
...
I am tracking weekly scores in a table and want to be able to calculate a
4-entry trailing average. Not every cell will have a value, so the last 4
entries might be spread over more than 4 cells in the row. For example,
tracking player point totals over a period of weeks, a player might be
sick
one week and thus not have points that week, so the cell would be blank
(as
opposed to zero).



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default Formula to average the last 4 non-blank numerical cells of a r

Ron Coderre wrote...
....
=SUMPRODUCT(ISNUMBER(MATCH(COLUMN(A1:J1),LARGE((( A1:J1<0)*COLUMN(A1:J1))
+((A1:J1=0)*0),{1,2,3,4}),0))*A1:J1)/4

....

As long as A1:J1 doesn't contain any error values, (A1:J1=0)*0 is
ALWAYS {0,0,0,0,0,0,0,0,0,0}. No point including it in this formula.



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Formula to average the last 4 non-blank numerical cells of a r

Good point, Harlan.....as always, your insight is appreciated.

***********
Regards,
Ron

XL2002, WinXP


"Harlan Grove" wrote:

Ron Coderre wrote...
....
=SUMPRODUCT(ISNUMBER(MATCH(COLUMN(A1:J1),LARGE((( A1:J1<0)*COLUMN(A1:J1))
+((A1:J1=0)*0),{1,2,3,4}),0))*A1:J1)/4

....

As long as A1:J1 doesn't contain any error values, (A1:J1=0)*0 is
ALWAYS {0,0,0,0,0,0,0,0,0,0}. No point including it in this formula.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating only non-empty cells... Jay Excel Worksheet Functions 9 September 22nd 06 03:20 AM
average formula ingoring empty cells jenparker1234 Excel Worksheet Functions 3 July 12th 06 04:42 AM
Sumif Cells Are Not Blank Powlaz Excel Worksheet Functions 12 March 15th 06 04:40 PM
average price of 4 columns of figures but some cells can be blank bpeltzer Excel Worksheet Functions 0 February 13th 06 08:37 PM
I want to copy a formula n Excel but skip any blank cells Ann Excel Worksheet Functions 1 December 12th 05 06:55 PM


All times are GMT +1. The time now is 09:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"