#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default average if

I'm trying to average the last 30 values in a column.
Column A contains a date and Column B contains a value for that date.
A running average of the last 30 days (or 1-month) needs to be kept so
that if new data is entered the average automatically updates.

any ideas?

I was thinking something like
=AVERAGEIFS(B:B,A:A,LARGE(A:A,30))

but the greater than seems to muck things yup.

thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default average if

What if there aren't 30 values to average?

Are there any empty cells within the range?

--
Biff
Microsoft Excel MVP


"~slacker~" wrote in message
...
I'm trying to average the last 30 values in a column.
Column A contains a date and Column B contains a value for that date.
A running average of the last 30 days (or 1-month) needs to be kept so
that if new data is entered the average automatically updates.

any ideas?

I was thinking something like
=AVERAGEIFS(B:B,A:A,LARGE(A:A,30))

but the greater than seems to muck things yup.

thanks



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default average if

no empty cells in the range.

it doesn't take long to get over 30 values but if it were less than
thirty then i'd want to average the 20 or whatever values that there
were.
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default average if

Try this:

=IF(COUNT(B:B),AVERAGE(OFFSET(B2,COUNT(B:B)-1,,MAX(-COUNT(B:B),-30))),"")

--
Biff
Microsoft Excel MVP


"~slacker~" wrote in message
...
no empty cells in the range.

it doesn't take long to get over 30 values but if it were less than
thirty then i'd want to average the 20 or whatever values that there
were.



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default average if

thats perfect thanks!

although i don't understand the use of the if. seems it will always
be true and is not needed.


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default average if

The IF(COUNT(...)... makes sure there is at least 1 number in the range. If
there were no numbers to average then you'd get a #DIV/0! error.
IF(COUNT(...)... prevents that error. You can remove it if you don't need
it.

--
Biff
Microsoft Excel MVP


"~slacker~" wrote in message
...
thats perfect thanks!

although i don't understand the use of the if. seems it will always
be true and is not needed.



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
A formula to AVERAGE IF but only average a set number of values [email protected] Excel Worksheet Functions 2 January 31st 08 08:28 PM
Find monthly average but have average automatically configured kimbafred Excel Discussion (Misc queries) 2 August 8th 07 12:28 AM
Error Handling #N/A with AVERAGE Function - Average of values in Row Sam via OfficeKB.com Excel Worksheet Functions 13 July 31st 05 03:59 PM
Weighed Average of a weiged average when there are blanks krl - ExcelForums.com Excel Discussion (Misc queries) 1 July 6th 05 07:37 PM
how does one convert text to a formula "average(A:A)" to =average( phshirk Excel Worksheet Functions 4 April 14th 05 01:20 AM


All times are GMT +1. The time now is 10:16 PM.

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

About Us

"It's about Microsoft Excel"